Module: wine Branch: master Commit: 4a929eaf9702b9c7bed215c5b6f9784c2f66339c URL: https://gitlab.winehq.org/wine/wine/-/commit/4a929eaf9702b9c7bed215c5b6f9784...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Dec 15 13:15:56 2023 +0100
user32: Support utf-8 in WM_CHAR W->A conversion.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55655
---
dlls/user32/message.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 86c6593e192..07dfbdb0f85 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -183,9 +183,9 @@ BOOL map_wparam_AtoW( UINT message, WPARAM *wparam, enum wm_char_mapping mapping */ static void map_wparam_WtoA( MSG *msg, BOOL remove ) { - BYTE ch[4]; + BYTE ch[4] = { 0 }; WCHAR wch[2]; - DWORD len; + DWORD i, len; DWORD cp;
switch(msg->message) @@ -195,7 +195,6 @@ static void map_wparam_WtoA( MSG *msg, BOOL remove ) { cp = get_input_codepage(); wch[0] = LOWORD(msg->wParam); - ch[0] = ch[1] = 0; len = WideCharToMultiByte( cp, 0, wch, 1, (LPSTR)ch, 2, NULL, NULL ); if (len == 2) /* DBCS char */ { @@ -224,14 +223,12 @@ static void map_wparam_WtoA( MSG *msg, BOOL remove ) cp = get_input_codepage(); wch[0] = LOWORD(msg->wParam); wch[1] = HIWORD(msg->wParam); - ch[0] = ch[1] = 0; - WideCharToMultiByte( cp, 0, wch, 2, (LPSTR)ch, 4, NULL, NULL ); - msg->wParam = MAKEWPARAM( ch[0] | (ch[1] << 8), 0 ); + len = WideCharToMultiByte( cp, 0, wch, 2, (LPSTR)ch, 4, NULL, NULL ); + for (msg->wParam = i = 0; i < len; i++) msg->wParam |= ch[i] << (8 * i); break; case WM_IME_CHAR: cp = get_input_codepage(); wch[0] = LOWORD(msg->wParam); - ch[0] = ch[1] = 0; len = WideCharToMultiByte( cp, 0, wch, 1, (LPSTR)ch, 2, NULL, NULL ); if (len == 2) msg->wParam = MAKEWPARAM( (ch[0] << 8) | ch[1], HIWORD(msg->wParam) );