aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/sdl/sdl.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index b9cccbf5e8..c89a560976 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -774,6 +774,17 @@ char *OSystem_SDL::convertEncoding(const char *to, const char *from, const char
zeroBytes = 2;
if (Common::String(from).hasPrefixIgnoreCase("utf-32"))
zeroBytes = 4;
+
+ // SDL_iconv_string() takes char * instead of const char * as it's third parameter
+ // with some older versions of SDL.
+#if SDL_VERSION_ATLEAST(2, 0, 0)
return SDL_iconv_string(to, from, string, length + zeroBytes);
+#else
+ char *stringCopy = (char *) calloc(sizeof(char), length + zeroBytes);
+ memcpy(stringCopy, string, length);
+ char *result = SDL_iconv_string(to, from, stringCopy, length + zeroBytes);
+ free(stringCopy);
+ return result;
+#endif
}