diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index abcc73e5d31..a72a42b0937 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -91,8 +91,10 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) && (how->flags & GTL_USECRLF) && !editor->bEmulateVersion10) /* Ignore GTL_USECRLF flag in 1.0 emulation */ length += editor->nParagraphs - 1; - - if (how->flags & GTL_NUMBYTES) + + if (how->flags & GTL_NUMBYTES || + (how->flags & GTL_PRECISE && /* GTL_PRECISE seems to imply GTL_NUMBYTES */ + !(how->flags & GTL_NUMCHARS))) /* unless GTL_NUMCHARS is given */ { CPINFO cpinfo; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 1fbdaa5bf8a..ee266836f0f 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -5540,6 +5540,45 @@ static void test_EM_GETTEXTLENGTHEX(void) ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); ok(ret == 6, "ret %d\n",ret); + /* Unicode/NUMCHARS/NUMBYTES */ + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string_2); + + gtl.flags = GTL_DEFAULT; + gtl.codepage = 1200; + ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0); + ok(ret == lstrlen(test_string_2), + "GTL_DEFAULT gave %i, expected %i\n", ret, lstrlen(test_string_2)); + + gtl.flags = GTL_NUMCHARS; + gtl.codepage = 1200; + ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0); + ok(ret == lstrlen(test_string_2), + "GTL_NUMCHARS gave %i, expected %i\n", ret, lstrlen(test_string_2)); + + gtl.flags = GTL_NUMBYTES; + gtl.codepage = 1200; + ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0); + ok(ret == lstrlen(test_string_2)*2, + "GTL_NUMBYTES gave %i, expected %i\n", ret, lstrlen(test_string_2)*2); + + gtl.flags = GTL_PRECISE; + gtl.codepage = 1200; + ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0); + ok(ret == lstrlen(test_string_2)*2, + "GTL_PRECISE gave %i, expected %i\n", ret, lstrlen(test_string_2)*2); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE; + gtl.codepage = 1200; + ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0); + ok(ret == lstrlen(test_string_2), + "GTL_NUMCHAR | GTL_PRECISE gave %i, expected %i\n", ret, lstrlen(test_string_2)); + + gtl.flags = GTL_NUMCHARS | GTL_NUMBYTES; + gtl.codepage = 1200; + ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0); + ok(ret == E_INVALIDARG, + "GTL_NUMCHARS | GTL_NUMBYTES gave %i, expected %i\n", ret, E_INVALIDARG); + DestroyWindow(hwnd); }