mirror of https://github.com/AxioDL/nod.git
Removed codecvt
This commit is contained in:
parent
28ed4ba6af
commit
dcb83ff908
|
@ -1,5 +1,3 @@
|
|||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include "NOD/NOD.hpp"
|
||||
|
||||
namespace NOD
|
||||
|
@ -7,14 +5,29 @@ namespace NOD
|
|||
|
||||
std::string WideToUTF8(const std::wstring& src)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> 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<std::codecvt_utf8<wchar_t>> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue