mirror of https://github.com/AxioDL/metaforce.git
Removed codecvt
This commit is contained in:
parent
eb6f3237db
commit
199b8e7c32
|
@ -1 +1 @@
|
|||
Subproject commit 92898661cc318e2de2934e58607e8349a0d10d13
|
||||
Subproject commit 66cb6c982e8824fa887807bf8ba42376b301478b
|
|
@ -1 +1 @@
|
|||
Subproject commit 34f2f028a9e0c12b6827e93f7043339fecd84b75
|
||||
Subproject commit 154b84413050cdb03f281c42861b9af6eaef7d14
|
|
@ -1,20 +1,33 @@
|
|||
#include "HECL/HECL.hpp"
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
|
||||
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