From: YeshunYe yeyeshun@uniontech.com
Signed-off-by: YeshunYe yeyeshun@uniontech.com --- dlls/mlang/mlang.c | 5 ++++- dlls/mlang/tests/mlang.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c index e340a5f57c7..2a7b047a614 100644 --- a/dlls/mlang/mlang.c +++ b/dlls/mlang/mlang.c @@ -983,7 +983,10 @@ HRESULT WINAPI ConvertINetMultiByteToUnicode( default: if (*pcSrcSize == -1) *pcSrcSize = lstrlenA(pSrcStr); - + while (MultiByteToWideChar(dwEncoding, MB_ERR_INVALID_CHARS, pSrcStr, *pcSrcSize, 0, 0) == 0) + { + (*pcSrcSize)--; + } if (pDstStr) *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize); else diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c index c3d8274bb68..936b5a301e2 100644 --- a/dlls/mlang/tests/mlang.c +++ b/dlls/mlang/tests/mlang.c @@ -652,10 +652,10 @@ static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2) lenW = ARRAY_SIZE(bufW); ret = pConvertINetMultiByteToUnicode(NULL, 936, stringA936, (INT *)&lenA, bufW, (INT *)&lenW); ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret); - todo_wine ok(lenA == lstrlenA(stringA936) - 2, "expected lenA %u, got %u\n", lstrlenA(stringA936) - 2, lenA); + ok(lenA == lstrlenA(stringA936) - 2, "expected lenA %u, got %u\n", lstrlenA(stringA936) - 2, lenA); expected_len = MultiByteToWideChar(936, 0, stringA936, lenA, NULL, 0); ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW); - todo_wine ok(!memcmp(bufW, stringW936, lenW * sizeof(WCHAR)), "bufW/stringW mismatch\n"); + ok(!memcmp(bufW, stringW936, lenW * sizeof(WCHAR)), "bufW/stringW mismatch\n");
/* IMultiLanguage2_ConvertStringFromUnicode tests */