mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-27 14:58:32 +00:00
Common: Rename UTF16ToUTF8
This function does *not* always convert from UTF-16. It converts from UTF-16 on Windows and UTF-32 on other operating systems. Also renaming UTF8ToUTF16 for consistency, even though it technically doesn't have the same problem since it only was implemented on Windows.
This commit is contained in:
parent
cd51552fe4
commit
15d9fab0bb
14 changed files with 31 additions and 31 deletions
|
@ -457,29 +457,29 @@ std::string UTF16ToCP(u32 code_page, std::wstring_view input)
|
|||
return output;
|
||||
}
|
||||
|
||||
std::wstring UTF8ToUTF16(std::string_view input)
|
||||
std::wstring UTF8ToWString(std::string_view input)
|
||||
{
|
||||
return CPToUTF16(CP_UTF8, input);
|
||||
}
|
||||
|
||||
std::string UTF16ToUTF8(std::wstring_view input)
|
||||
std::string WStringToUTF8(std::wstring_view input)
|
||||
{
|
||||
return UTF16ToCP(CP_UTF8, input);
|
||||
}
|
||||
|
||||
std::string SHIFTJISToUTF8(std::string_view input)
|
||||
{
|
||||
return UTF16ToUTF8(CPToUTF16(CODEPAGE_SHIFT_JIS, input));
|
||||
return WStringToUTF8(CPToUTF16(CODEPAGE_SHIFT_JIS, input));
|
||||
}
|
||||
|
||||
std::string UTF8ToSHIFTJIS(std::string_view input)
|
||||
{
|
||||
return UTF16ToCP(CODEPAGE_SHIFT_JIS, UTF8ToUTF16(input));
|
||||
return UTF16ToCP(CODEPAGE_SHIFT_JIS, UTF8ToWString(input));
|
||||
}
|
||||
|
||||
std::string CP1252ToUTF8(std::string_view input)
|
||||
{
|
||||
return UTF16ToUTF8(CPToUTF16(CODEPAGE_WINDOWS_1252, input));
|
||||
return WStringToUTF8(CPToUTF16(CODEPAGE_WINDOWS_1252, input));
|
||||
}
|
||||
|
||||
std::string UTF16BEToUTF8(const char16_t* str, size_t max_size)
|
||||
|
@ -487,7 +487,7 @@ std::string UTF16BEToUTF8(const char16_t* str, size_t max_size)
|
|||
const char16_t* str_end = std::find(str, str + max_size, '\0');
|
||||
std::wstring result(static_cast<size_t>(str_end - str), '\0');
|
||||
std::transform(str, str_end, result.begin(), static_cast<u16 (&)(u16)>(Common::swap16));
|
||||
return UTF16ToUTF8(result);
|
||||
return WStringToUTF8(result);
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -572,7 +572,7 @@ std::string UTF8ToSHIFTJIS(std::string_view input)
|
|||
return CodeTo("SJIS", "UTF-8", input);
|
||||
}
|
||||
|
||||
std::string UTF16ToUTF8(std::wstring_view input)
|
||||
std::string WStringToUTF8(std::wstring_view input)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
|
||||
return converter.to_bytes(input.data(), input.data() + input.size());
|
||||
|
@ -591,7 +591,7 @@ std::string UTF16BEToUTF8(const char16_t* str, size_t max_size)
|
|||
std::filesystem::path StringToPath(std::string_view path)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return std::filesystem::path(UTF8ToUTF16(path));
|
||||
return std::filesystem::path(UTF8ToWString(path));
|
||||
#else
|
||||
return std::filesystem::path(path);
|
||||
#endif
|
||||
|
@ -602,7 +602,7 @@ std::filesystem::path StringToPath(std::string_view path)
|
|||
std::string PathToString(const std::filesystem::path& path)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return UTF16ToUTF8(path.native());
|
||||
return WStringToUTF8(path.native());
|
||||
#else
|
||||
return path.native();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue