mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-14 05:55:13 +01:00
Merge pull request #5717 from FearlessTobi/port-5895
Port yuzu-emu/yuzu#5895: "string_util: Remove MSVC workaround for converting between UTF8/UTF16"
This commit is contained in:
commit
5c58620618
@ -136,27 +136,13 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string UTF16ToUTF8(const std::u16string& input) {
|
std::string UTF16ToUTF8(const std::u16string& input) {
|
||||||
#ifdef _MSC_VER
|
|
||||||
// Workaround for missing char16_t/char32_t instantiations in MSVC2017
|
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
|
|
||||||
std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend());
|
|
||||||
return convert.to_bytes(tmp_buffer);
|
|
||||||
#else
|
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||||
return convert.to_bytes(input);
|
return convert.to_bytes(input);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::u16string UTF8ToUTF16(const std::string& input) {
|
std::u16string UTF8ToUTF16(const std::string& input) {
|
||||||
#ifdef _MSC_VER
|
|
||||||
// Workaround for missing char16_t/char32_t instantiations in MSVC2017
|
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
|
|
||||||
auto tmp_buffer = convert.from_bytes(input);
|
|
||||||
return std::u16string(tmp_buffer.cbegin(), tmp_buffer.cend());
|
|
||||||
#else
|
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||||
return convert.from_bytes(input);
|
return convert.from_bytes(input);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user