User Tools

Site Tools


c:string:string-to-wstring

Convert std::string to std::wstring

std::wstring to_wstring(std::string const & s) {
	std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> convert;
	auto asInt = convert.from_bytes(s);
	return std::wstring(reinterpret_cast<wchar_t const *>(asInt.data()), asInt.length());
}
c/string/string-to-wstring.txt · Last modified: 2019/06/16 22:40 by odefta