1.使用windows api方式转换
MultiByteToWideChar()
WideCharToMultiByte()
需要包含头文件<Windows.h>
1 void StringToWstring_WindowApi(const string &str, wstring &wstr) 2 { 3 int nLen = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.size(), NULL, 0); 4 wchar_t* buffer = new wchar_t[nLen + 1]; 5 6 MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.size(), buffer, nLen); 7 8 buffer[nLen] = '