Skip to content

Commit

Permalink
ExConverter.cpp: Workaround for the problem that Wine does not suppor…
Browse files Browse the repository at this point in the history
…t UCS2-BE(1201) as the source code page for IMultiLanguage::ConvertStringToUnicode()
  • Loading branch information
sdottaka committed Apr 23, 2024
1 parent 5b9a417 commit bc6ef61
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Src/Common/ExConverter.cpp
Expand Up @@ -128,7 +128,25 @@ class CExconverterMLang: public IExconverter {
HRESULT hr = m_pmlang->ConvertStringToUnicode(&m_mlangcookie, srcCodepage, (char *)src, &uisrcbytes, dest, &uidestchars);
*srcbytes = uisrcbytes;
*destchars = uidestchars;
return SUCCEEDED(hr) ? true : false;
if (SUCCEEDED(hr))
return true;
if (srcCodepage != ucr::CP_UCS2BE)
return false;
#ifdef POCO_ARCH_BIG_ENDIAN
return false;
#else
// Workaround for the problem that Wine does not support UCS2-BE(1201) as the source code page for IMultiLanguage::ConvertStringToUnicode()
if (uisrcbytes > 0)
{
for (size_t i = 0; i < uisrcbytes - 1; i += 2)
dest[i >> 1] = (src[i] << 8) + src[i + 1];
if ((uisrcbytes % 2) == 1)
memcpy(reinterpret_cast<unsigned char*>(dest) + uisrcbytes - 1, src + uisrcbytes - 1, 1);
}
*srcbytes = uisrcbytes;
*destchars = uisrcbytes;
return true;
#endif
}

void clearCookie()
Expand Down

0 comments on commit bc6ef61

Please sign in to comment.