diff options
author | Cameron Cawley | 2019-04-02 20:23:13 +0100 |
---|---|---|
committer | Filippos Karapetis | 2019-04-04 01:06:30 +0300 |
commit | e4b78f4f621a7d73c08099c3b7674f3966cf8da4 (patch) | |
tree | 65c558b9ce3c96246f35a6ad558ab3171076e6b8 /backends/platform/sdl | |
parent | ca054ba0b97ae555926340364294f3204b960833 (diff) | |
download | scummvm-rg350-e4b78f4f621a7d73c08099c3b7674f3966cf8da4.tar.gz scummvm-rg350-e4b78f4f621a7d73c08099c3b7674f3966cf8da4.tar.bz2 scummvm-rg350-e4b78f4f621a7d73c08099c3b7674f3966cf8da4.zip |
WIN32: Ensure the translated dialog strings are using the correct encoding
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/win32/win32_wrapper.cpp | 28 | ||||
-rw-r--r-- | backends/platform/sdl/win32/win32_wrapper.h | 6 |
2 files changed, 26 insertions, 8 deletions
diff --git a/backends/platform/sdl/win32/win32_wrapper.cpp b/backends/platform/sdl/win32/win32_wrapper.cpp index aa3a05fa48..7efcb00aa1 100644 --- a/backends/platform/sdl/win32/win32_wrapper.cpp +++ b/backends/platform/sdl/win32/win32_wrapper.cpp @@ -29,6 +29,7 @@ #include <shlobj.h> #include "common/scummsys.h" +#include "common/translation.h" #include "backends/platform/sdl/win32/win32_wrapper.h" // VerSetConditionMask, VerifyVersionInfo and SHGetFolderPath didn't appear until Windows 2000, @@ -80,28 +81,43 @@ bool confirmWindowsVersion(int majorVersion, int minorVersion) { return VerifyVersionInfoFunc(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask); } -wchar_t *ansiToUnicode(const char *s) { - DWORD size = MultiByteToWideChar(0, 0, s, -1, NULL, 0); +wchar_t *ansiToUnicode(const char *s, uint codePage) { + DWORD size = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0); if (size > 0) { LPWSTR result = new WCHAR[size]; - if (MultiByteToWideChar(0, 0, s, -1, result, size) != 0) + if (MultiByteToWideChar(codePage, 0, s, -1, result, size) != 0) return result; } return NULL; } -char *unicodeToAnsi(const wchar_t *s) { - DWORD size = WideCharToMultiByte(0, 0, s, -1, NULL, 0, 0, 0); +char *unicodeToAnsi(const wchar_t *s, uint codePage) { + DWORD size = WideCharToMultiByte(codePage, 0, s, -1, NULL, 0, 0, 0); if (size > 0) { char *result = new char[size]; - if (WideCharToMultiByte(0, 0, s, -1, result, size, 0, 0) != 0) + if (WideCharToMultiByte(codePage, 0, s, -1, result, size, 0, 0) != 0) return result; } return NULL; } +uint getCurrentCharset() { +#ifdef USE_TRANSLATION + Common::String charset = TransMan.getCurrentCharset(); + if (charset == "iso-8859-2") + return 28592; + if (charset == "iso-8859-5") + return 28595; + if (charset == "iso-8859-7") + return 28597; + if (charset == "iso-8859-8") + return 28598; +#endif + return 28591; +} + } diff --git a/backends/platform/sdl/win32/win32_wrapper.h b/backends/platform/sdl/win32/win32_wrapper.h index d42838d1e1..8bd60239df 100644 --- a/backends/platform/sdl/win32/win32_wrapper.h +++ b/backends/platform/sdl/win32/win32_wrapper.h @@ -45,7 +45,7 @@ bool confirmWindowsVersion(int majorVersion, int minorVersion); * * @note Return value must be freed by the caller. */ -wchar_t *ansiToUnicode(const char *s); +wchar_t *ansiToUnicode(const char *s, uint codePage = CP_ACP); /** * Converts a Windows wide-character string into a C string. * Used to interact with Win32 Unicode APIs with no ANSI fallback. @@ -55,7 +55,9 @@ wchar_t *ansiToUnicode(const char *s); * * @note Return value must be freed by the caller. */ -char *unicodeToAnsi(const wchar_t *s); +char *unicodeToAnsi(const wchar_t *s, uint codePage = CP_ACP); + +uint getCurrentCharset(); } |