Fixed ICU support for CP_ACP
@@ -181,8 +181,10 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
switch (CodePage)
{
+ case CP_ACP:
case CP_UTF8:
break;
+
default:
WLog_ERR(TAG, "Unsupported encoding %u", CodePage);
return 0;
@@ -193,8 +195,8 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
targetStart = lpWideCharStr;
targetCapacity = cchWideChar;
-
error = U_ZERO_ERROR;
+
if (cchWideChar == 0)
{
u_strFromUTF8(NULL, 0, &targetLength,
@@ -209,11 +211,11 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
}
}
#else
+
if (cchWideChar == 0)
{
sourceStart = (const BYTE*) lpMultiByteStr;
targetStart = (WCHAR*) NULL;
-
result = ConvertUTF8toUTF16(&sourceStart, &sourceStart[cbMultiByte],
&targetStart, NULL, strictConversion);
length = targetStart - ((WCHAR*) NULL);
@@ -222,7 +224,6 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
{
sourceStart = (const BYTE*) lpMultiByteStr;
targetStart = lpWideCharStr;
-
result = ConvertUTF8toUTF16(&sourceStart, &sourceStart[cbMultiByte],
&targetStart, &targetStart[cchWideChar], strictConversion);
length = targetStart - ((WCHAR*) lpWideCharStr);
@@ -302,8 +303,10 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
switch (CodePage)
{
+ case CP_ACP:
case CP_UTF8:
break;
+
default:
WLog_ERR(TAG, "Unsupported encoding %u", CodePage);
return 0;
@@ -314,8 +317,8 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
targetStart = lpMultiByteStr;
targetCapacity = cbMultiByte;
-
error = U_ZERO_ERROR;
+
if (cbMultiByte == 0)
{
u_strToUTF8(NULL, 0, &targetLength,
@@ -330,21 +333,19 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
}
}
#else
+
if (cbMultiByte == 0)
{
sourceStart = (WCHAR*) lpWideCharStr;
targetStart = (BYTE*) NULL;
-
result = ConvertUTF16toUTF8(&sourceStart, &sourceStart[cchWideChar],
&targetStart, NULL, strictConversion);
-
length = targetStart - ((BYTE*) NULL);
}
else
{
sourceStart = (WCHAR*) lpWideCharStr;
targetStart = (BYTE*) lpMultiByteStr;
-
result = ConvertUTF16toUTF8(&sourceStart, &sourceStart[cchWideChar],
&targetStart, &targetStart[cbMultiByte], strictConversion);
length = targetStart - ((BYTE*) lpMultiByteStr);
