diff --git a/lib/WideStringConvert.cpp b/lib/WideStringConvert.cpp index 6976f2f..1f254bd 100644 --- a/lib/WideStringConvert.cpp +++ b/lib/WideStringConvert.cpp @@ -1,5 +1,3 @@ -#include -#include #include "NOD/NOD.hpp" namespace NOD @@ -7,14 +5,29 @@ namespace NOD std::string WideToUTF8(const std::wstring& src) { - std::wstring_convert> conv; - return conv.to_bytes(src); + std::string retval; + retval.reserve(src.length()); + for (wchar_t ch : src) + { + char mb[4]; + int c = std::wctomb(mb, ch); + retval.append(mb, c); + } + return retval; } std::wstring UTF8ToWide(const std::string& src) { - std::wstring_convert> conv; - return conv.from_bytes(src); + std::wstring retval; + retval.reserve(src.length()); + const char* buf = src.c_str(); + while (*buf) + { + wchar_t wc; + buf += std::mbtowc(&wc, buf, MB_CUR_MAX); + retval += wc; + } + return retval; } }