From: YeshunYe yeyeshun@uniontech.com
Signed-off-by: YeshunYe yeyeshun@uniontech.com --- dlls/mlang/mlang.c | 25 ++++++++++++++++++++++++- dlls/mlang/tests/mlang.c | 8 ++++---- 2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c index e340a5f57c7..968f118d52a 100644 --- a/dlls/mlang/mlang.c +++ b/dlls/mlang/mlang.c @@ -983,7 +983,30 @@ HRESULT WINAPI ConvertINetMultiByteToUnicode( default: if (*pcSrcSize == -1) *pcSrcSize = lstrlenA(pSrcStr); - + if (*pcSrcSize) + { + int cursor = 0; + CPINFOEXA info = { 0 }; + GetCPInfoExA(dwEncoding, 0, &info); + if (info.CodePage == 932 || info.CodePage == 936 || + info.CodePage == 949 || info.CodePage == 950 || + info.CodePage == 1361) + { + while (cursor < *pcSrcSize) + { + if (IsDBCSLeadByte(pSrcStr[cursor])) + { + cursor++; + if (cursor >= *pcSrcSize) + { + *pcSrcSize = cursor - 1; + break; + } + } + cursor++; + } + } + } 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 c9f6f450c0e..e52440cd079 100644 --- a/dlls/mlang/tests/mlang.c +++ b/dlls/mlang/tests/mlang.c @@ -654,20 +654,20 @@ static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2) lenW = ARRAY_SIZE(bufW); ret = pConvertINetMultiByteToUnicode(NULL, 936, bad936A_end, (INT *)&lenA, bufW, (INT *)&lenW); ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret); - todo_wine ok(lenA == lstrlenA(bad936A_end) - 2, "expected lenA %u, got %u\n", lstrlenA(bad936A_end) - 2, lenA); + ok(lenA == lstrlenA(bad936A_end) - 2, "expected lenA %u, got %u\n", lstrlenA(bad936A_end) - 2, lenA); expected_len = MultiByteToWideChar(936, 0, bad936A_end, lenA, NULL, 0); ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW); - todo_wine ok(!memcmp(bufW, bad936W_end, lenW * sizeof(WCHAR)), "bufW/stringW mismatch\n"); + ok(!memcmp(bufW, bad936W_end, lenW * sizeof(WCHAR)), "bufW/stringW mismatch\n");
memset(bufW, 'x', sizeof(bufW)); lenA = lstrlenA(bad936A_mid); lenW = ARRAY_SIZE(bufW); ret = pConvertINetMultiByteToUnicode(NULL, 936, bad936A_mid, (INT *)&lenA, bufW, (INT *)&lenW); ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret); - todo_wine ok(lenA == lstrlenA(bad936A_mid), "expected lenA %u, got %u\n", lstrlenA(bad936A_mid), lenA); + ok(lenA == lstrlenA(bad936A_mid), "expected lenA %u, got %u\n", lstrlenA(bad936A_mid), lenA); expected_len = MultiByteToWideChar(936, 0, bad936A_mid, lenA, NULL, 0); ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW); - todo_wine ok(!memcmp(bufW, bad936W_mid, lenW * sizeof(WCHAR)), "bufW/stringW mismatch\n"); + ok(!memcmp(bufW, bad936W_mid, lenW * sizeof(WCHAR)), "bufW/stringW mismatch\n");
/* IMultiLanguage2_ConvertStringFromUnicode tests */