mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 14:24:56 +00:00
Removed codecvt
This commit is contained in:
2
hecl/extern/Athena
vendored
2
hecl/extern/Athena
vendored
Submodule hecl/extern/Athena updated: 92898661cc...66cb6c982e
2
hecl/extern/LogVisor
vendored
2
hecl/extern/LogVisor
vendored
Submodule hecl/extern/LogVisor updated: 34f2f028a9...154b844130
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user