mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-07 01:17:14 +00:00
Replace unsafe (wchar_t*)pchText casts with uint16_to_wstring() in all keyboard callbacks. The direct cast is incorrect on platforms where wchar_t is 4 bytes (Linux/macOS). New helpers in StringHelpers route through u16string for proper UTF-16 to wchar_t conversion. - Add uint16_len, uint16_to_u16string, uint16_to_wstring to StringHelpers - Fix casts in AnvilMenu, CreateWorldMenu, DebugCreateSchematic, DebugSetCamera, LaunchMoreOptionsMenu, SignEntryMenu - Truncate sign text to 15 chars in SignEntryMenu - Move m_bIgnoreInput reset after if-block in LaunchMoreOptionsMenu
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
#pragma once
|
|
// using namespace stdtd;
|
|
|
|
std::wstring toLower(const std::wstring& a);
|
|
std::wstring trimString(const std::wstring& a);
|
|
std::wstring replaceAll(const std::wstring& in, const std::wstring& replace,
|
|
const std::wstring& with);
|
|
|
|
bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b);
|
|
// 4J-PB - for use in the ::toString
|
|
template <class T>
|
|
std::wstring _toString(T t) {
|
|
std::wostringstream oss;
|
|
oss << std::dec << t;
|
|
return oss.str();
|
|
}
|
|
template <class T>
|
|
T _fromString(const std::wstring& s) {
|
|
std::wistringstream stream(s);
|
|
T t;
|
|
stream >> t;
|
|
return t;
|
|
}
|
|
template <class T>
|
|
T _fromHEXString(const std::wstring& s) {
|
|
std::wistringstream stream(s);
|
|
T t;
|
|
stream >> std::hex >> t;
|
|
return t;
|
|
}
|
|
|
|
size_t uint16_len(const uint16_t* str);
|
|
std::u16string uint16_to_u16string(const uint16_t* str);
|
|
std::wstring uint16_to_wstring(const uint16_t* str);
|
|
|
|
std::wstring convStringToWstring(const std::string& converting);
|
|
std::wstring u16string_to_wstring(const std::u16string& converting);
|
|
std::u16string wstring_to_u16string(const std::wstring& converting);
|
|
const char* wstringtofilename(const std::wstring& name);
|
|
std::wstring filenametowstring(const char* name);
|
|
|
|
std::vector<std::wstring>& stringSplit(const std::wstring& s, wchar_t delim,
|
|
std::vector<std::wstring>& elems);
|
|
std::vector<std::wstring> stringSplit(const std::wstring& s, wchar_t delim);
|
|
|
|
void stripWhitespaceForHtml(std::wstring& string, bool bRemoveNewline = true);
|
|
std::wstring escapeXML(const std::wstring& in);
|
|
std::wstring parseXMLSpecials(const std::wstring& in);
|