wstring转string wstring转char*

来源:互联网 发布:php error log 日志 编辑:程序博客网 时间:2024/06/07 04:59
wstring转换为string
wstring wstr=_T("你猜你猜"); 
int size=WideCharToMultiByte(CP_ACP,0,wstr.c_str(),-1,NULL,0,NULL,NULL); 
char *ch=new char[size+1]; 
if(!WideCharToMultiByte(CP_ACP,0,wstr.c_str(),-1,ch,size,NULL,NULL)) 

    return false; 

string str=ch;