64,282
社区成员
发帖
与我相关
我的任务
分享
int main(void)
{
string str="abc";//utf8
string dst;//ansi
wstring wstr;
int len = MultiByteToWideChar(CP_UTF8,0,str.c_str(),str.size(),NULL,0);
wstr.resize(len);
MultiByteToWideChar(CP_UTF8,0,str.c_str(),str.size(),&wstr[0],len);
len=WideCharToMultiByte(CP_ACP,0,wstr.c_str(),wstr.size(),NULL,0,NULL,NULL);
dst.resize(len);
WideCharToMultiByte(CP_ACP,0,wstr.c_str(),wstr.size(),&dst[0],len,NULL,NULL);
cout<<dst<<endl;
system("pause");
return 0;
}