[Scummvm-git-logs] scummvm master -> e4b78f4f621a7d73c08099c3b7674f3966cf8da4
bluegr
bluegr at gmail.com
Thu Apr 4 00:06:34 CEST 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e4b78f4f62 WIN32: Ensure the translated dialog strings are using the correct encoding
Commit: e4b78f4f621a7d73c08099c3b7674f3966cf8da4
https://github.com/scummvm/scummvm/commit/e4b78f4f621a7d73c08099c3b7674f3966cf8da4
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2019-04-04T01:06:30+03:00
Commit Message:
WIN32: Ensure the translated dialog strings are using the correct encoding
Changed paths:
backends/dialogs/win32/win32-dialogs.cpp
backends/platform/sdl/win32/win32_wrapper.cpp
backends/platform/sdl/win32/win32_wrapper.h
diff --git a/backends/dialogs/win32/win32-dialogs.cpp b/backends/dialogs/win32/win32-dialogs.cpp
index fca0601..d9f7bf9 100644
--- a/backends/dialogs/win32/win32-dialogs.cpp
+++ b/backends/dialogs/win32/win32-dialogs.cpp
@@ -138,11 +138,11 @@ Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const ch
hr = dialog->SetOptions(dwOptions);
}
- LPWSTR str = Win32::ansiToUnicode(title);
+ LPWSTR str = Win32::ansiToUnicode(title, Win32::getCurrentCharset());
hr = dialog->SetTitle(str);
delete[] str;
- str = Win32::ansiToUnicode(_("Choose"));
+ str = Win32::ansiToUnicode(_("Choose"), Win32::getCurrentCharset());
hr = dialog->SetOkButtonLabel(str);
delete[] str;
diff --git a/backends/platform/sdl/win32/win32_wrapper.cpp b/backends/platform/sdl/win32/win32_wrapper.cpp
index aa3a05f..7efcb00 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 d42838d..8bd6023 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();
}
More information about the Scummvm-git-logs
mailing list