C/C++,Windows/MFC__char与TCHAR相互转化
来源:互联网 发布:徐州八方网络 编辑:程序博客网 时间:2024/05/18 15:50
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
- C/C++,Windows/MFC__char与TCHAR相互转化
- char与TCHAR相互转化
- char与TCHAR相互转化
- char与TCHAR相互转化
- char与TCHAR相互转化
- TCHAR 与CHAR的相互转化
- Objective-c 字符串与整型相互转化
- C++/C关于字符串的使用与相互转化
- char* TCHAR* String相互转化
- double与string的相互转化(C++)
- 【Obj-C】UIImage与位图(RGBA8 Bitmaps)的相互转化
- double与string的相互转化(C++)
- C/C++ 字符串与数字相互转化方法小结
- double与string的相互转化(C++)
- C/C++ --- double与string的相互转化
- C/C++字符串与数字的相互转化
- Windows下char与TCHAR(WCHAR)相互转换
- TCHAR和char 的相互转化
- hdu 5375 多校
- sunburnt 学习笔记 (五)模糊查询
- shell脚本回顾01:脚本跟踪和脚本参数
- Big Number(1212)
- HDU 2036 改革春风吹满地
- C/C++,Windows/MFC__char与TCHAR相互转化
- Hadoop API的改变
- Ray Wenderlich的swift教程03--提醒视图控制器UIAlertController
- Spring中的Aop即:面向切面
- NSOperation使用
- Android网络状况查询
- 学校集训心得DAY8.11-8.12
- 【大创_社区划分】——PageRank算法MapReduce实现
- pojApple Tree(树状数组)