Unicode下Cstring to char*

来源:互联网 发布:序列密码算法 编辑:程序博客网 时间:2024/05/18 05:51

 

 

CString P_Cstring=  _T("我的字符串");//需要被转化的Cstring
int nLength = P_Cstring.GetLength();
int nBytes = WideCharToMultiByte(CP_ACP,0,P_Cstring,nLength,NULL,0,NULL,NULL);
char*  P_char= new char[ nBytes];
memset(P_char,0,nBytes + 1);
WideCharToMultiByte(CP_OEMCP, 0, P_Cstring, nLength, P_char, nBytes, NULL, NULL);