Unicode下CString转char*
2016-01-17 15:19
357 查看
说明:我的CString内部封装的是wchar_t(宽字符)
方法1:使用WideCharToMultiByte
方法2:使用W2A或T2A
USES_CONVERSION;//声明宏
char *pinfo = W2A(ShowInfo);//内容过大时会导致栈溢出,目前测试数据量长度为40万没有问题,52万时提示栈溢出
//处理。。。
其中ShowInfo是CString类型。
说明:我的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类型。
相关文章推荐
- Linux 与 Windows 对UNICODE 的处理方式
- Unicode详细分析解释
- vbs中将GB2312转Unicode的代码
- 程序员趣味读物 谈谈Unicode编码
- 常用字符集编码详解(ASCII GB2312 GBK GB18030 unicode UTF-8)
- C#实现Json转Unicode的方法
- UTF-8、Unicode 标准化表单、BOM
- 浅谈Unicode与JavaScript的发展史
- JavaScript中字符串与Unicode编码互相转换的实现方法
- php utf-8转unicode的函数第1/2页
- php UTF-8、Unicode和BOM问题
- Unicode 编码转换器
- javascript下汉字和Unicode编码互转代码
- string,CString,char*之间的转化
- PHP如何实现Unicode和Utf-8编码相互转换
- PHP解码unicode编码的中文字符代码分享
- 浅析c++ 宏 #val 在unicode下的使用
- 简单谈谈php中的unicode和utf8编码
- 趣谈Unicode、Ascii、utf-8、GB2312、GBK等编码知识
- vbs实现unicode和ascii编码转换