mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
win95: fallback to strdup when MultiByteToWideChar fails (it only works with MSLU)
This commit is contained in:
parent
5e2a3ec3ff
commit
3318cd969b
@ -297,6 +297,10 @@ static char* mb_to_mb_string_alloc(const char *str,
|
||||
return strdup(str);
|
||||
#else
|
||||
|
||||
/* Windows 95 will return 0 from these functions with a UTF8 codepage set without MSLU. From an unknown MSDN version (others omit this info):
|
||||
* - CP_UTF8 Windows 98/Me, Windows NT 4.0 and later: Translate using UTF-8. When this is set, dwFlags must be zero.
|
||||
* - Windows 95: Under the Microsoft Layer for Unicode, MultiByteToWideChar also supports CP_UTF7 and CP_UTF8.
|
||||
*/
|
||||
path_buf_wide_len = MultiByteToWideChar(cp_in, 0, str, -1, NULL, 0);
|
||||
|
||||
if (path_buf_wide_len)
|
||||
@ -334,9 +338,16 @@ static char* mb_to_mb_string_alloc(const char *str,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(path_buf_wide);
|
||||
return strdup(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return strdup(str);
|
||||
|
||||
if (path_buf_wide)
|
||||
free(path_buf_wide);
|
||||
@ -385,6 +396,8 @@ wchar_t* utf8_to_utf16_string_alloc(const char *str)
|
||||
|
||||
out_len = MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, len);
|
||||
}
|
||||
else
|
||||
return strdup(str);
|
||||
|
||||
if (out_len < 0)
|
||||
{
|
||||
@ -442,6 +455,8 @@ char* utf16_to_utf8_string_alloc(const wchar_t *str)
|
||||
|
||||
out_len = WideCharToMultiByte(CP_UTF8, 0, str, -1, buf, len, NULL, NULL);
|
||||
}
|
||||
else
|
||||
return strdup(str);
|
||||
|
||||
if (out_len < 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user