cpp中std::string和std::wstring 相互转换
作者:互联网
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
std::wstring s2ws(const std::string& str)
{
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
return converterX.from_bytes(str);
}
std::string ws2s(const std::wstring& wstr)
{
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
return converterX.to_bytes(wstr);
}
标签:std,convert,string,wstring,converterX,include 来源: https://www.cnblogs.com/nocanstillbb/p/14801045.html