CString和string在unicode与非unicode下的相互转换
来源:互联网 发布:windows 开发周期 编辑:程序博客网 时间:2024/04/28 11:59
CString和string在unicode与非unicode下的相互转换
最近想写一个手机控制电脑的玩具,涉及到了socket通信,数据采用json通用格式,首先是jsoncpp的编译问题太烦了,然后还有更烦的,java中的String多容易的玩意儿,然后到了c/c++/mfc中超级烦,搜索了很久的攻略,用了大把的时间,最后写了个这玩意儿出来,或许可以帮助到一些需要此的道友们哈
string toString(CString cs) { #ifdef _UNICODE//如果是unicode工程USES_CONVERSION;std::string str(W2A(cs));return str;#else//如果是多字节工程 std::string str(cs.GetBuffer());cs.ReleaseBuffer();return str; #endif // _UNICODE }CString toCString(string str) {#ifdef _UNICODE//如果是unicode工程USES_CONVERSION; CString s(str.c_str());CString ans(str.c_str());return ans;#else//如果是多字节工程 //string 转 CStringCString ans;ans.Format("%s", str.c_str());return ans; #endif // _UNICODE }
3 0
- CString和string在unicode与非unicode下的相互转换
- Unicode下的CString与String之间的相互转换
- Unicode下的CString与String之间的相互转换
- c++ unicode模式下CString 到string的相互转换
- Unicode 下char*与CString相互转换
- Unicode 下 CString 与 char* 相互转换的问题
- vc在unicode和非unicode情况下cstring转换为float
- CString 和 std::string在unicode下比较安全的转换方向[续]
- unicode与string之间的相互转换
- CString与std::string unicode下相互转化
- Unicode与String相互转换
- VC程序Unicode字符集下CString与char *相互转换
- Unicode模式下CString 与const WCHAR*、WCHAR*相互转换
- Unicode下CString与char*的转换
- Unicode下的CString与char *转换
- Unicode下的CString与char *转换
- Unicode和String相互转换
- CString 和 std::string 转换方法(Unicode下)
- Make递归调用之参数传递
- 使用 comment-net-ftp-3.5.jar 实现FTPClient时遇到的listFiles()返回空的问题小结
- 深究AngularJS——排序
- 验证码6位自动生成器第四讲(1)
- String类:品读API
- CString和string在unicode与非unicode下的相互转换
- 使用json更新solr索引
- 卷皮网BI校招试题
- 系统架构师成长之路(一)
- Type Encodings property_getAttributes
- 系统架构师成长之路(二)
- MediaPlayer和Service用法
- Objective简介
- 字符串分割--java中String.split()用法