From 41d3a70c5848267916d01c26b99b4b2991ae1d0e Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Wed, 14 Aug 2019 20:47:04 +0200 Subject: SDL: Fix convertEncoding for multibyte encodings. --- backends/platform/sdl/sdl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 105a232b77..0139bac29d 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -771,7 +771,12 @@ int SDL_SetColorKey_replacement(SDL_Surface *surface, Uint32 flag, Uint32 key) { char *OSystem_SDL::convertEncoding(const char *to, const char *from, const char *string, size_t length) { #if SDL_VERSION_ATLEAST(2, 0, 0) debug("Trying SDL..."); - return SDL_iconv_string(to, from, string, length + 1); + int zeroBytes = 1; + if (Common::String(from).hasPrefixIgnoreCase("utf-16")) + zeroBytes = 2; + if (Common::String(from).hasPrefixIgnoreCase("utf-32")) + zeroBytes = 4; + return SDL_iconv_string(to, from, string, length + zeroBytes); #else debug("SDL isn't available"); return nullptr; -- cgit v1.2.3