WM_CHAR interprets the character codes using a code page tied to the keyboard layout, not CP_ACP. Also skip the test if WideCharToMultiByte() used the default character since that breaks the round-trip. Trace the code page when skipping the tests.
From: Francois Gouget fgouget@codeweavers.com
WM_CHAR interprets the character codes using a code page tied to the keyboard layout, not CP_ACP. Also skip the test if WideCharToMultiByte() used the default character since that breaks the round-trip. Trace the code page when skipping the tests.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=54424 --- dlls/user32/tests/edit.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index 78328ee1729..bbde9b16616 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -3368,15 +3368,22 @@ static void test_wordbreak_proc(void)
static void test_dbcs_WM_CHAR(void) { + HKL hkl; + UINT cp; WCHAR textW[] = { 0x4e00, 0x4e8c, 0x4e09, 0 }; /* one, two, three */ unsigned char bytes[7]; + BOOL hasdefault; HWND hwnd[2]; int i;
- WideCharToMultiByte(CP_ACP, 0, textW, -1, (char *)bytes, ARRAY_SIZE(bytes), NULL, NULL); - if (!IsDBCSLeadByte(bytes[0])) + hkl = GetKeyboardLayout( 0 ); + if (!GetLocaleInfoW(LOWORD(hkl), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (WCHAR *)&cp, sizeof(cp) / sizeof(WCHAR))) + cp = CP_ACP; + + WideCharToMultiByte(cp, WC_NO_BEST_FIT_CHARS, textW, -1, (char *)bytes, ARRAY_SIZE(bytes), NULL, &hasdefault); + if (hasdefault || !IsDBCSLeadByteEx(cp, bytes[0])) { - skip("Skipping DBCS WM_CHAR test in this codepage\n"); + skip("Skipping DBCS WM_CHAR test in the %d codepage\n", cp); return; } hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); @@ -3396,6 +3403,7 @@ static void test_dbcs_WM_CHAR(void) r = SetWindowTextA(hwnd[i], ""); ok(r, "SetWindowText failed\n");
+ /* sending the lead byte separately works for DBCS locales */ for (p = bytes; *p; p++) PostMessageA(hwnd[i], WM_CHAR, *p, 1);
Thanks for the patch. I'll withdraw my MR, https://gitlab.winehq.org/wine/wine/-/merge_requests/2173.