Experimental cross platform utf8 support.
This commit is contained in:
parent
d6dd68bcef
commit
3d44b7ccc5
3 changed files with 23 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <cassert>
|
||||
#include <fmt/core.h>
|
||||
#include <iostream>
|
||||
#include <utf8.h>
|
||||
|
||||
namespace guecs {
|
||||
using std::make_shared;
|
||||
|
|
@ -237,7 +238,14 @@ namespace guecs {
|
|||
}
|
||||
|
||||
wstring to_wstring(const string& str) {
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> $converter;
|
||||
return $converter.from_bytes(str);
|
||||
std::wstring result = L"";
|
||||
|
||||
try {
|
||||
utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result));
|
||||
} catch(const utf8::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue