From: Akihiro Sagawa sagawa.aki@gmail.com
User32 uses the input codepage in Unicode edit control. However, it uses ANSI codepage, i.e. CP_ACP, in ANSI version control.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54424 --- dlls/user32/tests/edit.c | 39 +++++++++++++++++++++++++-------------- dlls/user32/tests/msg.c | 2 +- 2 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index 78328ee1729..c3a4485dc3a 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -32,6 +32,8 @@ #define ID_EDITTEST2 99 #define MAXLEN 200
+extern DWORD get_input_codepage( void ); + static BOOL open_clipboard(HWND hwnd) { DWORD start = GetTickCount(); @@ -3366,17 +3368,17 @@ static void test_wordbreak_proc(void) DestroyWindow(hwnd); }
-static void test_dbcs_WM_CHAR(void) +static void test_WM_CHAR(void) { - WCHAR textW[] = { 0x4e00, 0x4e8c, 0x4e09, 0 }; /* one, two, three */ - unsigned char bytes[7]; + static const WCHAR textW[] = { 0x4e00, 0x4e8c, 0x00d7, '!', 0 }; /* one, two, x, ! */ + CPINFO cpinfo; HWND hwnd[2]; int i;
- WideCharToMultiByte(CP_ACP, 0, textW, -1, (char *)bytes, ARRAY_SIZE(bytes), NULL, NULL); - if (!IsDBCSLeadByte(bytes[0])) + GetCPInfo(CP_ACP, &cpinfo); + if (cpinfo.MaxCharSize > 2) { - skip("Skipping DBCS WM_CHAR test in this codepage\n"); + skip("Skipping legacy WM_CHAR test in UTF-8 codepage\n"); return; } hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); @@ -3385,8 +3387,9 @@ static void test_dbcs_WM_CHAR(void) for (i = 0; i < ARRAY_SIZE(hwnd); i++) { const unsigned char* p; - WCHAR strW[4]; - char str[7]; + WCHAR bufW[10], strW[10]; + char buf[10], str[10]; + DWORD cp; MSG msg; BOOL r; int n; @@ -3396,21 +3399,29 @@ static void test_dbcs_WM_CHAR(void) r = SetWindowTextA(hwnd[i], ""); ok(r, "SetWindowText failed\n");
- for (p = bytes; *p; p++) + cp = i ? get_input_codepage() : CP_ACP; + n = WideCharToMultiByte(cp, 0, textW, -1, buf, ARRAY_SIZE(buf), NULL, NULL); + ok(n > 0, "WideCharToMultiByte failed\n"); + + for (p = (unsigned char*)buf; *p; p++) PostMessageA(hwnd[i], WM_CHAR, *p, 1);
while (PeekMessageA(&msg, hwnd[i], 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
+ n = MultiByteToWideChar(cp, 0, buf, -1, bufW, ARRAY_SIZE(bufW)); + ok(n > 0, "MultiByteToWideChar failed\n"); n = GetWindowTextW(hwnd[i], strW, ARRAY_SIZE(strW)); ok(n > 0, "GetWindowTextW failed\n"); - ok(!wcscmp(strW, textW), "got %s, expected %s\n", - wine_dbgstr_w(strW), wine_dbgstr_w(textW)); + ok(!wcscmp(strW, bufW), "got %s, expected %s\n", + wine_dbgstr_w(strW), wine_dbgstr_w(bufW));
+ n = WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, ARRAY_SIZE(buf), NULL, NULL); + ok(n > 0, "WideCharToMultiByte failed\n"); n = GetWindowTextA(hwnd[i], str, ARRAY_SIZE(str)); ok(n > 0, "GetWindowText failed\n"); - ok(!strcmp(str, (char*)bytes), "got %s, expected %s\n", - wine_dbgstr_a(str), wine_dbgstr_a((char *)bytes)); + ok(!strcmp(str, buf), "got %s, expected %s\n", + wine_dbgstr_a(str), wine_dbgstr_a(buf));
DestroyWindow(hwnd[i]);
@@ -3455,7 +3466,7 @@ START_TEST(edit) test_paste(); test_EM_GETLINE(); test_wordbreak_proc(); - test_dbcs_WM_CHAR(); + test_WM_CHAR();
UnregisterWindowClasses(); } diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index cca211cc22a..56d0509d63a 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -15669,7 +15669,7 @@ static void test_SetForegroundWindow(void) DestroyWindow(hwnd); }
-static DWORD get_input_codepage( void ) +extern DWORD get_input_codepage( void ) { DWORD cp; int ret;