char与TCHAR相互转化
来源:互联网 发布:java与传感器通信 编辑:程序博客网 时间:2024/05/26 05:51
char与TCHAR之间的转化主要用到函数MultiByteToWideChar和WideCharToMultiByte
char转TCHAR
TCHAR转char
char转TCHAR
如果不是Unicode字符集,就不需要转换,直接复制即可,如果不确定是否使用Unicode字符集,可以这样写
- char strUsr[10] = "Hello";
- TCHAR Name[100];
- #ifdef UNICODE
- MultiByteToWideChar(CP_ACP, 0, strUsr, -1, Name, 100);
- #else
- strcpy(Name, strUsr);
- #endif
- char* ConvertLPWSTRToLPSTR (LPWSTR lpwszStrIn)
- {
- LPSTR pszOut = NULL;
- if (lpwszStrIn != NULL)
- {
- int nInputStrLen = wcslen (lpwszStrIn);
- // Double NULL Termination
- int nOutputStrLen = WideCharToMultiByte (CP_ACP, 0, lpwszStrIn, nInputStrLen, NULL, 0, 0, 0) + 2;
- pszOut = new char [nOutputStrLen];
- if (pszOut)
- {
- memset (pszOut, 0x00, nOutputStrLen);
- WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, pszOut, nOutputStrLen, 0, 0);
- }
- }
- return pszOut;
- }
阅读全文
0 0
- char与TCHAR相互转化
- char与TCHAR相互转化
- char与TCHAR相互转化
- char与TCHAR相互转化
- TCHAR 与CHAR的相互转化
- char* TCHAR* String相互转化
- TCHAR和char 的相互转化
- TCHAR和char 的相互转化
- char与Tchar之间相互装换
- char*与LPCTSTR相互转化
- char[]与string相互转化
- Windows下char与TCHAR(WCHAR)相互转换
- C/C++,Windows/MFC__char与TCHAR相互转化
- char* Tchar* wxString相互转换
- CString char* TCHAR* 转化问题
- CString char TCHAR的转化
- mfc TCHAR转为char转化
- char* 与 WCHAR* 的相互转化
- Eclipse中使用Servlet
- php 可变变量
- Socket心跳包,Socket长连接之旅
- Spark数据本地性
- 拖拽之实例购物车
- char与TCHAR相互转化
- css 知识点记录
- C语言SOCKET编程
- 信号量
- unity ugui图片自适应文字内容大小
- Lucene同义词检索同时精确提取自定义关键词(Lucene版本5.3.0)
- JavaMail入门第一篇 邮件简介及API概述
- 《Java专栏》— 集合框架
- JQuery Validate(1)---电话号码与邮箱验证