diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c index 1b13f127156..ecd8523365c 100644 --- a/dlls/ntdll/rtlstr.c +++ b/dlls/ntdll/rtlstr.c @@ -1610,6 +1610,9 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf ) /* Check for an odd length ... pass if even. */ if (len & 1) out_flags |= IS_TEXT_UNICODE_ODD_LENGTH; + if (((char *)buf)[len - 1] == 0) + len--; /* Windows seems to do something like that to avoid e.g. false IS_TEXT_UNICODE_NULL_BYTES */ + len /= sizeof(WCHAR); /* Windows only checks the first 256 characters */ if (len > 256) len = 256; diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c index 65b9b5217cd..e40bd53e03c 100644 --- a/dlls/ntdll/tests/rtlstr.c +++ b/dlls/ntdll/tests/rtlstr.c @@ -1677,7 +1677,7 @@ static void test_RtlIsTextUnicode(void) int flags; int i; - todo_wine ok(!pRtlIsTextUnicode(ascii, sizeof(ascii), NULL), "ASCII text detected as Unicode\n"); + ok(!pRtlIsTextUnicode(ascii, sizeof(ascii), NULL), "ASCII text detected as Unicode\n"); ok(pRtlIsTextUnicode(unicode, sizeof(unicode), NULL), "Text should be Unicode\n"); ok(!pRtlIsTextUnicode(unicode, sizeof(unicode) - 1, NULL), "Text should be Unicode\n");