common\string_util.cpp: switch to boost::locale::conv for UTF16ToUTF8() and UTF8ToUTF16() (#6623)
This commit is contained in:
		
							
								
								
									
										2
									
								
								externals/boost
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								externals/boost
									
									
									
									
										vendored
									
									
								
							 Submodule externals/boost updated: 80a171a179...32f5cd8ebb
									
								
							| @@ -139,11 +139,6 @@ add_library(citra_common STATIC | |||||||
| ) | ) | ||||||
|  |  | ||||||
| if (MSVC) | 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 |   target_compile_options(citra_common PRIVATE | ||||||
|     /W4 |     /W4 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,12 +4,14 @@ | |||||||
|  |  | ||||||
| #include <algorithm> | #include <algorithm> | ||||||
| #include <cctype> | #include <cctype> | ||||||
| #include <codecvt> |  | ||||||
| #include <cstdlib> | #include <cstdlib> | ||||||
| #include <locale> | #include <locale> | ||||||
| #include <sstream> | #include <sstream> | ||||||
| #include <string> | #include <string> | ||||||
| #include <string_view> | #include <string_view> | ||||||
|  |  | ||||||
|  | #include <boost/locale/encoding_utf.hpp> | ||||||
|  |  | ||||||
| #include "common/common_paths.h" | #include "common/common_paths.h" | ||||||
| #include "common/logging/log.h" | #include "common/logging/log.h" | ||||||
| #include "common/string_util.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::string UTF16ToUTF8(std::u16string_view input) { | ||||||
|     std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; |     return boost::locale::conv::utf_to_utf<char>(input.data(), input.data() + input.size()); | ||||||
|     return convert.to_bytes(input.data(), input.data() + input.size()); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| std::u16string UTF8ToUTF16(std::string_view input) { | std::u16string UTF8ToUTF16(std::string_view input) { | ||||||
|     std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; |     return boost::locale::conv::utf_to_utf<char16_t>(input.data(), input.data() + input.size()); | ||||||
|     return convert.from_bytes(input.data(), input.data() + input.size()); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user