From 1d9de16091a048cf37485001bf9f9af9089edadb Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Sun, 12 Mar 2023 20:26:29 +0100 Subject: [PATCH] vbscript/tests: Fix the testChrError() tests in the mixed locale case. 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));