# Unicode 字符集
| 字符集 | 起始范围 | 结束范围 |
|---|---|---|
| ASCII | 0x0000 | 0x007F |
| ISO 8859-1 ASCII扩展码 | 0x0080 | 0x00FF |
| 希腊字母 | 0x0370 | 0x03FF |
| 西里尔文 | 0x0400 | 0x04FF |
| 亚美尼亚文 | 0x0530 | 0x058F |
| 希伯来语 | 0x0590 | 0x05FF |
| 中日韩 | 0x3000 | 0x9FFF |
| UTF-16:你好 | 0x4f60 | 0x597d |
| UTF-8:你好 | 0xe4bda0 | 0xe5a5bd |
Unicode,他只有一个字符集。代码的编制与ISO 10646-1标准相似的。
//主函数测试
int main() {
//setlocale(LC_ALL, "zh_CN.UTF-8");
//system("chcp 936 > /nul");
//system("chcp 65001 > /nul");
setlocale(LC_ALL, "chs");
system("chcp");
TCHAR tStr[] = _T("abc你好");
const TCHAR* tsz = _T("abc你好啊");
wprintf(L"%sn", tStr);
return 0;
}
宽字符
ANSI C, 通过一种叫"宽字符"的概念来支持多个字节代表一个字符的字符集。 ANSI C 还支持多字节字符集,如那些在中文,日语和韩语版本的Windows中支持的字符集。然而,这些多字节字符集被当作单字节值得字符串时,在那些字符串里一些字符改变了后续字符的含义。多字节字符集主要影响C语言运行库函数。 宽字符并不一定是Unicode。Unicode只是宽字符编码的一种实现。打印所有的Unicode字符
#define _CRT_SECURE_NO_WARNINGS #include#include int main() { setlocale(LC_ALL, "zh_CN.UTF-8"); char chr = 0x41; wchar_t str[3] = {0}; //str[0] = 0x4f60; //str[1] = 0x4f61; for (int i = 0x3000; i < 0x9FFF; i++) { str[0] = i; wprintf(L"%s: 0x%xn", str, str[0]); } printf("nn"); wprintf(L"%s", str); return 0; }



