CString str;WCHAR newStr[30];const char* tempStr=str;//tempStr相当于一个中间变量 int length=strlen(tempStr)+1;//长度length,单位为字节 int newLength=MultiByteToWideChar(CP_ACP,0, tempStr,length,NULL,0);//新长度newLength MultiByteToWideChar(CP_ACP,0, tempStr,length, newStr,newLength);注: 函数...
#include<string> using namespace std; //将string转换成wstring wstring string2wstring(string str) { wstring result; //获取缓冲区大小,并申请空间,缓冲区大小按字符计算 int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.size(), NULL, 0); TCHAR* buffer = new TCHAR[len + 1]; //...
usingnamespacestd; //将string转换成wstring wstringstring2wstring(stringstr) { wstringresult; //获取缓冲区大小,并申请空间,缓冲区大小按字符计算 intlen=MultiByteToWideChar(CP_ACP,0,str.c_str(),str.size(),NULL,0); TCHAR*buffer=newTCHAR[len+1]; //多字节编码转换成宽字节编码 MultiByteToWideChar(CP...