# Unicode 字符集
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"%s\n", tStr); return 0; }
ANSI C, 通过一种叫"宽字符"的概念来支持多个字节代表一个字符的字符集。 ANSI C 还支持多字节字符集,如那些在中文,日语和韩语版本的Windows中支持的字符集。然而,这些多字节字符集被当作单字节值得字符串时,在那些字符串里一些字符改变了后续字符的含义。多字节字符集主要影响C语言运行库函数。 宽字符并不一定是Unicode。Unicode只是宽字符编码的一种实现。
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <locale.h> 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 = 0x00; i < 0x7F; i++) { printf("%c", i); } */ for (int i = 0x3000; i < 0x9FFF; i++) { str[0] = i; wprintf(L"%s: 0x%x\n", str, str[0]); } printf("\n\n"); wprintf(L"%s", str); return 0; }