Use Win32 APIs for UTF-16<->UTF-8 conversion

std::codecvt is deprecated since C++17 and broken for some characters/locales
This commit is contained in:
Cameron Gutman
2024-02-11 15:16:41 -06:00
parent 8689469ea8
commit 69a3edd9b0
7 changed files with 113 additions and 41 deletions

View File

@@ -20,4 +20,20 @@ namespace platf {
std::chrono::nanoseconds
qpc_time_difference(int64_t performance_counter1, int64_t performance_counter2);
/**
* @brief Converts a UTF-8 string into a UTF-16 wide string.
* @param string The UTF-8 string.
* @return The converted UTF-16 wide string.
*/
std::wstring
from_utf8(const std::string &string);
/**
* @brief Converts a UTF-16 wide string into a UTF-8 string.
* @param string The UTF-16 wide string.
* @return The converted UTF-8 string.
*/
std::string
to_utf8(const std::wstring &string);
} // namespace platf