您的位置:首页 > 其它

Unicode下CString转char*

2016-01-17 15:19 357 查看

说明:我的CString内部封装的是wchar_t(宽字符)

方法1:使用WideCharToMultiByte

int length = ShowInfo.GetLength();
char *pinfo = new char[length * 2];
WideCharToMultiByte(CP_ACP, 0, m_ShowInfo, length, pinfo, length * 2, NULL, NULL);
//处理。。。
delete pinfo;


方法2:使用W2A或T2A

USES_CONVERSION;//声明宏
char *pinfo = W2A(ShowInfo);//内容过大时会导致栈溢出,目前测试数据量长度为40万没有问题,52万时提示栈溢出
//处理。。。
其中ShowInfo是CString类型。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unicode cstring