#include <stdio.h>
#include <locale.h>
#include <stdlib.h>
#include <wchar.h>
const int SIZE = 100;
int main(void)
{
wchar_t wstr[SIZE];
//wchar_t wstr[] = {0x5b89, 0x5353, 0};
/*本地化,设置语言运行环境*/
setlocale(LC_ALL, "Chinese-simplified"); // locale.h
//wscanf(L"%s", wstr);
// 如果编译时遇到Illegal byte sequence错误,
// 拿CodeBlocks这个IDE来说
// 请在Settings-Compiler-Global compiler settings-Compiler settings-Other options中
// 加上-finput-charset=GBK这个编译选项
wcscpy(wstr, L"HELLO世界hello"); // stdlib.h
int i;
for (i = 0; wstr[i]; ++i)
printf("%#06X\n", wstr[i]);
wprintf(L"%ls\n", wstr);
//fputws(wstr, stdout);
return 0;
}
输出结果:
0X0048
0X0045
0X004C
0X004C
0X004F
0X4E16
0X754C
0X0068
0X0065
0X006C
0X006C
0X006F
HELLO世界hello