mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-23 07:35:34 +00:00
Add text input support: safe uint16_t* to wstring conversion
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
This commit is contained in:
@@ -36,6 +36,19 @@ bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b) {
|
||||
return out;
|
||||
}
|
||||
|
||||
size_t uint16_len(const uint16_t* str) {
|
||||
return std::char_traits<char16_t>::length(
|
||||
reinterpret_cast<const char16_t*>(str));
|
||||
}
|
||||
|
||||
std::u16string uint16_to_u16string(const uint16_t* str) {
|
||||
return std::u16string(reinterpret_cast<const char16_t*>(str), uint16_len(str));
|
||||
}
|
||||
|
||||
std::wstring uint16_to_wstring(const uint16_t* str) {
|
||||
return u16string_to_wstring(uint16_to_u16string(str));
|
||||
}
|
||||
|
||||
std::wstring convStringToWstring(const std::string& converting) {
|
||||
std::wstring converted(converting.length(), L' ');
|
||||
copy(converting.begin(), converting.end(), converted.begin());
|
||||
|
||||
Reference in New Issue
Block a user