diff options
author | Jaromir Wysoglad | 2019-08-19 19:22:31 -0700 |
---|---|---|
committer | Filippos Karapetis | 2019-08-24 18:12:45 +0300 |
commit | 04b28b208de7973347699c8a8e2cd355f7dd77f6 (patch) | |
tree | 94f34f6a55d794ac184e731834a0d1dde8e02f9d | |
parent | f8ac40af7c2b687d8dd3ce2f5909ab3f78f4a4bd (diff) | |
download | scummvm-rg350-04b28b208de7973347699c8a8e2cd355f7dd77f6.tar.gz scummvm-rg350-04b28b208de7973347699c8a8e2cd355f7dd77f6.tar.bz2 scummvm-rg350-04b28b208de7973347699c8a8e2cd355f7dd77f6.zip |
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.
-rw-r--r-- | backends/platform/sdl/win32/win32.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index aa83a37df0..8562892ef5 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -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); |