mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
WIN32: Fix infinite loop when converting from utf32
Because of how cyrilic transliteration and UTF-32 is handled on Windows, it was unfortunately possible to get into an infinite loop of conversions. The string would get converted to UTF-32 when transliterating, but because windows backend conversion cannot convert from UTF-32, it would use Common::Ustr to convert it to UTF-8, which would again get converted to UTF-32 when transliterating and so on.
This commit is contained in:
parent
f8ac40af7c
commit
04b28b208d
@ -406,8 +406,8 @@ char *OSystem_Win32::convertEncoding(const char* to, const char *from, const cha
|
||||
// transliteration in Common::Encoding and Win32 cannot convert it
|
||||
if (Common::String(from).hasPrefixIgnoreCase("utf-32")) {
|
||||
Common::U32String UTF32Str((const uint32 *)string, length / 4);
|
||||
Common::String UTF8Str = Common::convertUtf32ToUtf8(UTF32Str);
|
||||
return Common::Encoding::convert(to, "utf-8", UTF8Str.c_str(), UTF8Str.size());
|
||||
string = Common::convertUtf32ToUtf8(UTF32Str).c_str();
|
||||
from = "utf-8";
|
||||
}
|
||||
if (Common::String(to).hasPrefixIgnoreCase("utf-32")) {
|
||||
char *UTF8Str = Common::Encoding::convert("utf-8", from, string, length);
|
||||
|
Loading…
Reference in New Issue
Block a user