Skip to content

Commit

Permalink
patch unsupported modes of WideCharToMultiByte
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Nov 10, 2023
1 parent ef1d881 commit d9d866e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion wrappers/kernel32.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,18 @@ BOOL WINAPI CORKEL32_FreeEnvironmentStringsW(LPWSTR param_0)
INT WINAPI CORKEL32_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, INT cchWideChar, LPSTR lpMultiByteStr, INT cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar)
{
INT r;
dwFlags = 0;

// Windows 95 doesn't support these flags and will throw an error if they're specified
const unsigned short WC_ERR_INVALID_CHARS = 0x80;
const unsigned short WC_NO_BEST_FIT_CHARS = 0x400;
dwFlags &= ~WC_NO_BEST_FIT_CHARS;
dwFlags &= ~WC_ERR_INVALID_CHARS;

// Windows 95 doesn't appear to support UTF-8 conversion, so we fallback to the default multibyte codepage
if (CodePage == CP_UTF8) {
CodePage = CP_ACP;
}

r = WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar);
Trace(TRACE_PASSTHROUGH, "WideCharToMultiByte, r = %i, CodePage = %u, dwFlags = %u", r, CodePage, dwFlags);
return r;
Expand Down

0 comments on commit d9d866e

Please sign in to comment.