VBscript actually uses the default code page of the user default locale which may not be the same as CP_THREAD_ACP. Also for locales that don't have an ANSI code page, such as Hindi, it falls back to UTF-8.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54003
--- Not sure how I missed the mixed locales case before. This time I made sure to run it in all of the TestBot's supported locales and it looks all good: https://testbot.winehq.org/JobDetails.pl?Key=130549
From: Francois Gouget fgouget@codeweavers.com
VBscript actually uses the default code page of the user default locale which may not be the same as CP_THREAD_ACP. Also for locales that don't have an ANSI code page, such as Hindi, it falls back to UTF-8.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54003 --- dlls/vbscript/tests/run.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 294b635ea41..65459711061 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -231,6 +231,7 @@ static const char *vt2a(VARIANT *v) */ static void detect_locale(void) { + UINT cp; CPINFOEXA cpinfo; HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); LANGID (WINAPI *pGetThreadUILanguage)(void) = (void*)GetProcAddress(kernel32, "GetThreadUILanguage"); @@ -239,8 +240,17 @@ static void detect_locale(void) PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_ENGLISH && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH);
- GetCPInfoExA( CP_THREAD_ACP, 0, &cpinfo ); - MaxCharSize = cpinfo.MaxCharSize; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (WCHAR*)&cp, sizeof(cp)); + if (cp) + { + GetCPInfoExA( cp, 0, &cpinfo ); + MaxCharSize = cpinfo.MaxCharSize; + } + else + { + /* No ANSI code page for that locale -> the fallback is UTF-8 */ + MaxCharSize = 4; + }
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER, (void*)&first_day_of_week, sizeof(first_day_of_week));
This merge request was approved by Jacek Caban.