1 #include
2 代码如下:
3
4 //使用ATL的W2A和A2W宏必须使用USES_CONVERSION
5 USES_CONVERSION;
6
7 //Unicode字符串
8 wchar_t* wszText=L"1.Unicode字符转换为ANSI;";
9 printf("%s\n",W2A(wszText));
10
11 //用wprintf输出非英文字符,需要设置当前的地域信息
12 setlocale(LC_ALL,"chs");
13
14 //ANSI字符串(ANSI:American National Standards Institute)
15 //中文内码MBCS:Multi-Byte character sets,英文内码SBCS:Single-Byte character sets)
16 char* szText="2.ANSI字符转换成Unicode.";
17 wprintf(L"%s\n",A2W(szText));