-
Notifications
You must be signed in to change notification settings - Fork 86
Fix character encoding conversion issues #249
Conversation
{ | ||
const u32 s = source ? (u32)wcslen(source) : 0; | ||
return wStringToMultibyte(destination, source, s); | ||
return utf8ToWString(destination, source.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a stringc
contain embedded nulls? If so, this shouldn’t delegate but use another from_bytes
:
conv.from_bytes(source.begin(), sorce.end())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to suggest it can't:
Lines 789 to 798 in 5b2f192
//! verify the existing string. | |
string<T>& validate() | |
{ | |
// truncate to existing null | |
u32 len = calclen(c_str()); | |
if (len != size()) | |
str.resize(len); | |
return *this; | |
} |
@@ -142,7 +144,7 @@ endif() | |||
# OpenGL | |||
|
|||
if(USE_SDL2) | |||
option(ENABLE_OPENGL3 "Enable OpenGL 3+" TRUE) | |||
option(ENABLE_OPENGL3 "Enable OpenGL 3+" FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! |
Continuation of #221. Fixes #216 and fixes luanti-org/luanti#13646.
The Irrlicht string conversion functions are not broken, they are just the wrong kind of conversion functions: Irrlicht uses
wide <-> multibyte
conversion functions in places where it should actually usewide <-> UTF-8
conversion functions. This usually works because the locale-defined multibyte encoding is UTF-8 in many environments, but sometimes, it doesn't.This PR introduces new
wide <-> UTF-8
conversion functions,utf8ToWString
andwStringToUTF8
, and uses them where appropriate.wStringToMultibyte
is not used anymore and has been removed,multibyteToWString
has been kept because it is still used in one place.EDIT: btw, "AutomatedTest" doesn't even compile on Windows.
To do
This PR is Ready for Review. Before merging, 69622fe should be reverted.
How to test
Compile Minetest on Windows with and without SDL. Set a weird combination of language settings. Verify that Unicode text is displayed/copied/whatever-ed correctly.