Modified UTF16BEUTF8 to just convert the UTF-16 C-string into a std::u16string, and pass it into CodeToUTF8 with the 'from' parameter being "UTF-16BE", rather than manually performing the big endian to little endian encoding.

This commit is contained in:
34will 2018-01-11 16:55:23 +00:00
parent ba111959fa
commit a949e98d9b
1 changed files with 1 additions and 3 deletions

View File

@ -570,9 +570,7 @@ std::string UTF16ToUTF8(const std::wstring& input)
std::string UTF16BEToUTF8(const char16_t* str, size_t max_size)
{
const char16_t* str_end = std::find(str, str + max_size, '\0');
std::u16string result(static_cast<size_t>(str_end - str), '\0');
std::transform(str, str_end, result.begin(), static_cast<u16 (&)(u16)>(Common::swap16));
return CodeToUTF8("UTF-16LE", result);
return CodeToUTF8("UTF-16BE", std::u16string(str, static_cast<size_t>(str_end - str)));
}
#endif