1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
string str="字符转换测试A"; wstring wstr=L"字符转换测试A";
int size1=WideCharToMultiByte(CP_ACP,0,wstr.c_str(),-1,NULL,0,NULL,false); char *dest1=new char[size1]; WideCharToMultiByte(CP_ACP,0,wstr.c_str(),-1,dest1,size1,NULL,false); cout<<dest1; delete[] dest1
int size2=MultiByteToWideChar(CP_ACP,0,str.c_str(),-1,NULL,0); WCHAR *dest2=new WCHAR[size2]; MultiByteToWideChar(CP_ACP,0,str.c_str(),-1,dest2,size2); delete[] dest2
|