#include <codecvt>
#include <string>
// convert UTF-8 string to wstring
std::wstring utf8_to_wstring (const std::string& str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
return myconv.from_bytes(str);
}
// convert wstring to UTF-8 string
std::string wstring_to_utf8 (const std::wstring& str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
return myconv.to_bytes(str);
}
'Development > C++' 카테고리의 다른 글
[C++] _MSC_VER (0) | 2020.12.04 |
---|---|
Signed vs Unsigned (0) | 2020.10.31 |
wstring to UTF-8 string (0) | 2020.09.17 |
[C++17] filesystem - String 형변환 (0) | 2020.09.17 |
string c_str()함수 (0) | 2020.09.17 |