From 60a9e8fb7e7c48d6371e87feed5bcb9ea550abd9 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 13 Nov 2016 14:56:52 +0000 Subject: [PATCH] Implement UTF-8 conversion using codecvt --- simgear/misc/strutils.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/simgear/misc/strutils.cxx b/simgear/misc/strutils.cxx index 48d8fea8..9fbcaf76 100644 --- a/simgear/misc/strutils.cxx +++ b/simgear/misc/strutils.cxx @@ -26,6 +26,7 @@ #include #include // strerror_r() and strerror_s() #include +#include // new in C++11 #include "strutils.hxx" @@ -401,6 +402,8 @@ std::wstring convertUtf8ToWString(const std::string& a) #ifdef SG_WINDOWS return convertMultiByteToWString(CP_UTF8, a); #else + std::wstring_convert, wchar_t> ucs2conv; + return ucs2conv.from_bytes(a); #endif } @@ -409,7 +412,8 @@ std::string convertWStringToUtf8(const std::wstring& w) #ifdef SG_WINDOWS return convertWStringToMultiByte(CP_UTF8, w); #else - + std::wstring_convert, wchar_t> ucs2conv; + return ucs2conv.to_bytes(w); #endif }