c:string:string-to-wstring
This is an old revision of the document!
Convert std::string to std::wstring
Don't use the convert variable inside the to_wstring function. It will make it perform slower.
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> convert; std::wstring to_wstring(std::string const & s) { auto asInt = convert.from_bytes(s); return std::wstring(reinterpret_cast<wchar_t const *>(asInt.data()), asInt.length()); }
c/string/string-to-wstring.1564152367.txt.gz · Last modified: 2023/07/04 19:36 (external edit)