windows: Manage WideCharToMultiByte vs Windows XP.

Reference Issue #8666.
This commit is contained in:
Ryan C. Gordon
2024-01-25 18:53:56 -05:00
parent 2144c2ac71
commit 1c5bc53738
5 changed files with 23 additions and 1 deletions

View File

@@ -795,13 +795,21 @@ end:
static char *hid_internal_UTF16toUTF8(const wchar_t *src)
{
char *dst = NULL;
#ifdef HIDAPI_USING_SDL_RUNTIME
int len = WIN_WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, NULL, 0, NULL, NULL);
#else
int len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, NULL, 0, NULL, NULL);
#endif
if (len) {
dst = (char*)calloc(len, sizeof(char));
if (dst == NULL) {
return NULL;
}
#ifdef HIDAPI_USING_SDL_RUNTIME
WIN_WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, dst, len, NULL, NULL);
#else
WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, dst, len, NULL, NULL);
#endif
}
return dst;