WIN32: Fix conversion of multibyte encodings.

This commit is contained in:
Jaromir Wysoglad 2019-08-14 21:42:11 -07:00 committed by Filippos Karapetis
parent 41d3a70c58
commit 4edf35e414

View file

@ -419,7 +419,7 @@ char *OSystem_Win32::convertEncoding(const char* to, const char *from, const cha
} }
WCHAR *tmpStr; WCHAR *tmpStr;
if (Common::String(from).equalsIgnoreCase("utf-16")) { if (Common::String(from).hasPrefixIgnoreCase("utf-16")) {
// Allocate space for string and 2 ending zeros // Allocate space for string and 2 ending zeros
tmpStr = (WCHAR *) calloc(sizeof(char), length + 2); tmpStr = (WCHAR *) calloc(sizeof(char), length + 2);
if (!tmpStr) { if (!tmpStr) {
@ -431,7 +431,7 @@ char *OSystem_Win32::convertEncoding(const char* to, const char *from, const cha
tmpStr = Win32::ansiToUnicode(string, Win32::getCodePageId(from)); tmpStr = Win32::ansiToUnicode(string, Win32::getCodePageId(from));
} }
if (Common::String(to).equalsIgnoreCase("utf-16")) if (Common::String(to).hasPrefixIgnoreCase("utf-16"))
return (char *) tmpStr; return (char *) tmpStr;
else { else {
result = Win32::unicodeToAnsi(tmpStr, Win32::getCodePageId(to)); result = Win32::unicodeToAnsi(tmpStr, Win32::getCodePageId(to));