方法一:(str从函数传参时可能出问题)
#include <codecvt>
#include <string>
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
std::wstring &wstr = converter.from_bytes(str);
转回 to_bytes
方法二:
#include <comutil.h>
#pragma comment(lib, "comsuppw.lib")
string to wstring:
_bstr_t t = str.c_str();
wchar_t* pwchar = (wchar_t*)t;
wstring result = pwchar;
wstring to string:
_bstr_t t = wstring.c_str();
char* pchar = (char*)t;
string result = pchar;