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:
Jaromir Wysoglad 2019-08-19 19:22:31 -07:00 committed by Filippos Karapetis
parent f8ac40af7c
commit 04b28b208d

View File

@ -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);