mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 13:30:47 -04:00
Reimplement sys_string_to_string using utfcpp
This commit is contained in:
parent
96a101310f
commit
caba64040c
@ -19,13 +19,9 @@
|
|||||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <climits>
|
|
||||||
#include <codecvt>
|
|
||||||
#include <locale>
|
|
||||||
#include <string>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
#include <utf8cpp/utf8.h>
|
#include <utf8cpp/utf8.h>
|
||||||
|
|
||||||
@ -126,8 +122,10 @@ std::chrono::milliseconds parse_time_with_unit(std::string const& str) {
|
|||||||
|
|
||||||
std::string sys_string_to_string(sys_string const& in) {
|
std::string sys_string_to_string(sys_string const& in) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
|
std::u16string tmp(in.size(), 0);
|
||||||
return converter.to_bytes(in);
|
std::transform(in.begin(), in.end(), tmp.begin(),
|
||||||
|
[](sys_char c) { return static_cast<char16_t>(c); });
|
||||||
|
return utf8::utf16to8(tmp);
|
||||||
#else
|
#else
|
||||||
return in;
|
return in;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user