From 04b28b208de7973347699c8a8e2cd355f7dd77f6 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Mon, 19 Aug 2019 19:22:31 -0700 Subject: 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. --- backends/platform/sdl/win32/win32.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform') 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); -- cgit v1.2.3