String中文转Wstring
#include <string> #include <iostream> #include <windows.h> using namespace std; int main() { wchar_t tmp[1000] = L"\0"; 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; }

浙公网安备 33010602011771号