1、A2W和W2A
在《Window核心编程》,多字节和宽字节之间转换比较麻烦的,MultiByteToWideChar函数和WideCharToMultiByte函数有足够多的参数的意义让我们去理解。那么使用ATL的一个很好的字符串的转换宏:A2W和W2A。
(1)A2W的用法:
- USES_CONVERSION;
- CString tmpStr;
- char*LineChar="fdsfdsa";
- const WCHAR * cLineChar = A2W(LineChar);
- tmpStr=cLineChar;
(2)W2A的用法:
- USES_CONVERSION;
- CString tmpStr;
- WCH LineChar="fdsfdsa";
- const char* cLineChar = A2W(LineChar);
2、A2T和T2A
(1)A2T的用法:
- USES_CONVERSION;
- char * pChar="char to cstring";
- CString cTemp=A2T(pChar);
(2)T2A的用法:
- USES_CONVERSION;
- CString cTemp =_T("char to cstring");
- char * pChar=A2T(pChar);