VS下的字符串转换
来源:互联网 发布:npm 淘宝镜像 编辑:程序博客网 时间:2024/05/16 01:52
最近写程序老师碰到字符串之间的转换,每次都记不住还是写个笔记记一下要不每次都查半天太费劲
CString 与 string之间的转换
//下面的两种方法VS2015都有错
//1.有错CString -》string
//CString str = finder.GetFileName();
//string strPath = W2A(str);//str.GetBuffer(0);
//2.VS2008没错CString -》string
//string strPath = str.GetBuffer(0);
//string strPath = (LPCSTR)(finder.GetFilePath());
//3.VS2015没有错CString -》string
USES_CONVERSION;
string strFileStr = W2A(m_strFind.GetBuffer());
//4.VS2015没有错 string ->CString
CString str = (LPCTSTR)strFilePath.c_str();//乱码
char ch[2048] = "";
sprintf(ch, "%s", strFilePath.c_str());
int num = MultiByteToWideChar(0, 0, ch, -1, NULL, 0);
wchar_t *lpstr1 = new wchar_t[num];
MultiByteToWideChar(0, 0, ch, -1, lpstr1, num);
/* sprintf(ch, "%s", finder.GetFileName());//只能读取首字符
用构造函数,参数传由cstring转换来的char* :
sring a( (LPSTR)(LPCTSTR)cstring );
string strPath = ch;*/
向wchar中赋值
MultiByteToWideChar(CP_ACP, 0, "测试程序", -1, strWchar, 128);
- VS下的字符串转换
- VS字符串时间转换用法
- VS下的中文显示问题-编码转换
- VS环境下MFC的几种类型转换
- VS2010下 字符串各进制之间的转换
- VS 开发中的字符串转换 (一)
- VS 开发中的字符串转换 (二)
- 讨论:VS 2003下的组件程序如何转换为2005下的组件程序?
- vs下CString转换成string
- C++下的数字和字符串间的转换
- VS里面的类型转换
- VS下的快捷键
- VS下的 SAL
- iOS下如何将UTF8字符串转换为GB2312字符串(或者其他编码的字符串)
- (转)不同框架下的C++字符串代码转换
- python 3.1下的字符串转换(备忘)
- C#下字符串与字节数组之间的相互转换
- Linux下jstring与char字符串类型之间的转换
- iOS OC 的命名规范
- iOS 缓存机制浅析
- OC基础-NSString的用法06
- iOS mac终端下的SQL语句
- 应用层协议
- VS下的字符串转换
- 编程测验-日志内容重排序
- IP地址分类编址
- 回来,回到好久不用的 csdn.
- open() "/usr/local/nginx/nginx-1.8.1/client_body_temp/0000000297" failed (13: Permission denied),
- 求一元二次方程组ax^2+bx+c的解
- 【机器学习算法模型】分类算法——支持向量机(暂缺)
- HTML+CSS编写静态网站-15 什么是CSS
- 【机器学习算法模型】分类算法——随机森林