Created
July 29, 2011 18:41
-
-
Save taxilian/1114451 to your computer and use it in GitHub Desktop.
utf8 conversion tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string wstring_to_utf8(const std::wstring& src) { | |
std::string out_str; | |
#ifdef _WIN32 | |
utf8::utf16to8(src.begin(), src.end(), std::back_inserter(out_str)); | |
#else | |
utf8::utf32to8(src.begin(), src.end(), std::back_inserter(out_str)); | |
#endif | |
return out_str; | |
} | |
std::wstring utf8_to_wstring(const std::string& src) { | |
std::wstring out_str; | |
#ifdef _WIN32 | |
utf8::utf8to16(src.begin(), src.end(), std::back_inserter(out_str)); | |
#else | |
utf8::utf8to32(src.begin(), src.end(), std::back_inserter(out_str)); | |
#endif | |
return out_str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment