String中文转Wstring

#include <string>
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    wchar_t tmp[1000] = L"";
    
    string s1 = "华盛顿,纽约,首都";
    wstring s2;

    setlocale(LC_ALL, "chs");
    cout << s1 << endl;
    MultiByteToWideChar(CP_ACP, 0, s1.c_str(), s1.length(), tmp, s1.length());
    s2.assign(tmp);
    wcout << s2 << endl;
    system("pause");

    return 0;
}
原文地址:https://www.cnblogs.com/Galesaur-wcy/p/14918889.html