common\string_util.cpp: switch to boost::locale::conv for UTF16ToUTF8() and UTF8ToUTF16() (#6623)

This commit is contained in:
SachinVin 2023-06-18 22:30:00 +05:30 committed by GitHub
parent 06db4ffb17
commit 4c8a98a321
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 11 deletions

2
externals/boost vendored

@ -1 +1 @@
Subproject commit 80a171a179c1f901e4f8dfc8962417f44865ceec
Subproject commit 32f5cd8ebb35b29ccb3860861bd285f80804bc85

View file

@ -139,11 +139,6 @@ add_library(citra_common STATIC
)
if (MSVC)
target_compile_definitions(citra_common PRIVATE
# The standard library doesn't provide any replacement for codecvt yet
# so we can disable this deprecation warning for the time being.
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
)
target_compile_options(citra_common PRIVATE
/W4

View file

@ -4,12 +4,14 @@
#include <algorithm>
#include <cctype>
#include <codecvt>
#include <cstdlib>
#include <locale>
#include <sstream>
#include <string>
#include <string_view>
#include <boost/locale/encoding_utf.hpp>
#include "common/common_paths.h"
#include "common/logging/log.h"
#include "common/string_util.h"
@ -155,13 +157,11 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
}
std::string UTF16ToUTF8(std::u16string_view input) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
return convert.to_bytes(input.data(), input.data() + input.size());
return boost::locale::conv::utf_to_utf<char>(input.data(), input.data() + input.size());
}
std::u16string UTF8ToUTF16(std::string_view input) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
return convert.from_bytes(input.data(), input.data() + input.size());
return boost::locale::conv::utf_to_utf<char16_t>(input.data(), input.data() + input.size());
}
#ifdef _WIN32