首页 > 代码库 > GBK
GBK
参考文献:http://blog.csdn.net/fmddlmyy/article/details/2288312
GBK编码空间0x8140~0xFE7E和0x8180~0xFEFE,一共23940个码位,定义了21003(汉字)+883(特殊符号)=21886个字符
类别 | 区名 | 范围 | 码位数 | 字符数 |
符号区 | 1区 | 0xA1A1~0xA9FE | 846 | 717 |
5区 | 0xA840~0xA97E和0xA880~0xA9A0 | 192 | 166 | |
汉字区 | 2区 | 0xB0A1~0xF7FE | 6768 | 6763 |
3区 | 0x8140~0xA07E和0x8180~0xA0FE | 6080 | 6080 | |
4区 | 0xAA40~0xFE7E和0xAA80~0xFEA0 | 8160 | 8160 | |
用户自定义区 | 用户区1 | 0xAAA1~0xAFFE | 564 | |
用户区2 | 0xF8A1~0xFEFE | 658 | ||
用户区3 | 0xA140~0xA77E和0xA180~0xA7A0 | 672 |
以下表格包含了所有的GBK字符(21886个)
{0x8140,0x817E},
{0x8180,0x81FE},
{0x8240,0x827E},
{0x8280,0x82FE},
{0x8340,0x837E},
{0x8380,0x83FE},
{0x8440,0x847E},
{0x8480,0x84FE},
{0x8540,0x857E},
{0x8580,0x85FE},
{0x8640,0x867E},
{0x8680,0x86FE},
{0x8740,0x877E},
{0x8780,0x87FE},
{0x8840,0x887E},
{0x8880,0x88FE},
{0x8940,0x897E},
{0x8980,0x89FE},
{0x8A40,0x8A7E},
{0x8A80,0x8AFE},
{0x8B40,0x8B7E},
{0x8B80,0x8BFE},
{0x8C40,0x8C7E},
{0x8C80,0x8CFE},
{0x8D40,0x8D7E},
{0x8D80,0x8DFE},
{0x8E40,0x8E7E},
{0x8E80,0x8EFE},
{0x8F40,0x8F7E},
{0x8F80,0x8FFE},
{0x9040,0x907E},
{0x9080,0x90FE},
{0x9140,0x917E},
{0x9180,0x91FE},
{0x9240,0x927E},
{0x9280,0x92FE},
{0x9340,0x937E},
{0x9380,0x93FE},
{0x9440,0x947E},
{0x9480,0x94FE},
{0x9540,0x957E},
{0x9580,0x95FE},
{0x9640,0x967E},
{0x9680,0x96FE},
{0x9740,0x977E},
{0x9780,0x97FE},
{0x9840,0x987E},
{0x9880,0x98FE},
{0x9940,0x997E},
{0x9980,0x99FE},
{0x9A40,0x9A7E},
{0x9A80,0x9AFE},
{0x9B40,0x9B7E},
{0x9B80,0x9BFE},
{0x9C40,0x9C7E},
{0x9C80,0x9CFE},
{0x9D40,0x9D7E},
{0x9D80,0x9DFE},
{0x9E40,0x9E7E},
{0x9E80,0x9EFE},
{0x9F40,0x9F7E},
{0x9F80,0x9FFE},
{0xA040,0xA07E},
{0xA080,0xA0FE},
{0xA1A1,0xA1FE},
{0xA2A1,0xA2AA},
{0xA2B1,0xA2E2},
{0xA2E5,0xA2EE},
{0xA2F1,0xA2FC},
{0xA3A1,0xA3FE},
{0xA4A1,0xA4F3},
{0xA5A1,0xA5F6},
{0xA6A1,0xA6B8},
{0xA6C1,0xA6D8},
{0xA6E0,0xA6EB},
{0xA6EE,0xA6F2},
{0xA6F4,0xA6F5},
{0xA7A1,0xA7C1},
{0xA7D1,0xA7F1},
{0xA840,0xA87E},
{0xA880,0xA895},
{0xA8A1,0xA8C0},
{0xA8C5,0xA8E9},
{0xA940,0xA957},
{0xA959,0xA95A},
{0xA95C,0xA95C},
{0xA960,0xA97E},
{0xA980,0xA996},
{0xA9A4,0xA9EF},
{0xAA40,0xAA7E},
{0xAA80,0xAAA0},
{0xAB40,0xAB7E},
{0xAB80,0xABA0},
{0xAC40,0xAC7E},
{0xAC80,0xACA0},
{0xAD40,0xAD7E},
{0xAD80,0xADA0},
{0xAE40,0xAE7E},
{0xAE80,0xAEA0},
{0xAF40,0xAF7E},
{0xAF80,0xAFA0},
{0xB040,0xB07E},
{0xB080,0xB0FE},
{0xB140,0xB17E},
{0xB180,0xB1FE},
{0xB240,0xB27E},
{0xB280,0xB2FE},
{0xB340,0xB37E},
{0xB380,0xB3FE},
{0xB440,0xB47E},
{0xB480,0xB4FE},
{0xB540,0xB57E},
{0xB580,0xB5FE},
{0xB640,0xB67E},
{0xB680,0xB6FE},
{0xB740,0xB77E},
{0xB780,0xB7FE},
{0xB840,0xB87E},
{0xB880,0xB8FE},
{0xB940,0xB97E},
{0xB980,0xB9FE},
{0xBA40,0xBA7E},
{0xBA80,0xBAFE},
{0xBB40,0xBB7E},
{0xBB80,0xBBFE},
{0xBC40,0xBC7E},
{0xBC80,0xBCFE},
{0xBD40,0xBD7E},
{0xBD80,0xBDFE},
{0xBE40,0xBE7E},
{0xBE80,0xBEFE},
{0xBF40,0xBF7E},
{0xBF80,0xBFFE},
{0xC040,0xC07E},
{0xC080,0xC0FE},
{0xC140,0xC17E},
{0xC180,0xC1FE},
{0xC240,0xC27E},
{0xC280,0xC2FE},
{0xC340,0xC37E},
{0xC380,0xC3FE},
{0xC440,0xC47E},
{0xC480,0xC4FE},
{0xC540,0xC57E},
{0xC580,0xC5FE},
{0xC640,0xC67E},
{0xC680,0xC6FE},
{0xC740,0xC77E},
{0xC780,0xC7FE},
{0xC840,0xC87E},
{0xC880,0xC8FE},
{0xC940,0xC97E},
{0xC980,0xC9FE},
{0xCA40,0xCA7E},
{0xCA80,0xCAFE},
{0xCB40,0xCB7E},
{0xCB80,0xCBFE},
{0xCC40,0xCC7E},
{0xCC80,0xCCFE},
{0xCD40,0xCD7E},
{0xCD80,0xCDFE},
{0xCE40,0xCE7E},
{0xCE80,0xCEFE},
{0xCF40,0xCF7E},
{0xCF80,0xCFFE},
{0xD040,0xD07E},
{0xD080,0xD0FE},
{0xD140,0xD17E},
{0xD180,0xD1FE},
{0xD240,0xD27E},
{0xD280,0xD2FE},
{0xD340,0xD37E},
{0xD380,0xD3FE},
{0xD440,0xD47E},
{0xD480,0xD4FE},
{0xD540,0xD57E},
{0xD580,0xD5FE},
{0xD640,0xD67E},
{0xD680,0xD6FE},
{0xD740,0xD77E},
{0xD780,0xD7F9},
{0xD840,0xD87E},
{0xD880,0xD8FE},
{0xD940,0xD97E},
{0xD980,0xD9FE},
{0xDA40,0xDA7E},
{0xDA80,0xDAFE},
{0xDB40,0xDB7E},
{0xDB80,0xDBFE},
{0xDC40,0xDC7E},
{0xDC80,0xDCFE},
{0xDD40,0xDD7E},
{0xDD80,0xDDFE},
{0xDE40,0xDE7E},
{0xDE80,0xDEFE},
{0xDF40,0xDF7E},
{0xDF80,0xDFFE},
{0xE040,0xE07E},
{0xE080,0xE0FE},
{0xE140,0xE17E},
{0xE180,0xE1FE},
{0xE240,0xE27E},
{0xE280,0xE2FE},
{0xE340,0xE37E},
{0xE380,0xE3FE},
{0xE440,0xE47E},
{0xE480,0xE4FE},
{0xE540,0xE57E},
{0xE580,0xE5FE},
{0xE640,0xE67E},
{0xE680,0xE6FE},
{0xE740,0xE77E},
{0xE780,0xE7FE},
{0xE840,0xE87E},
{0xE880,0xE8FE},
{0xE940,0xE97E},
{0xE980,0xE9FE},
{0xEA40,0xEA7E},
{0xEA80,0xEAFE},
{0xEB40,0xEB7E},
{0xEB80,0xEBFE},
{0xEC40,0xEC7E},
{0xEC80,0xECFE},
{0xED40,0xED7E},
{0xED80,0xEDFE},
{0xEE40,0xEE7E},
{0xEE80,0xEEFE},
{0xEF40,0xEF7E},
{0xEF80,0xEFFE},
{0xF040,0xF07E},
{0xF080,0xF0FE},
{0xF140,0xF17E},
{0xF180,0xF1FE},
{0xF240,0xF27E},
{0xF280,0xF2FE},
{0xF340,0xF37E},
{0xF380,0xF3FE},
{0xF440,0xF47E},
{0xF480,0xF4FE},
{0xF540,0xF57E},
{0xF580,0xF5FE},
{0xF640,0xF67E},
{0xF680,0xF6FE},
{0xF740,0xF77E},
{0xF780,0xF7FE},
{0xF840,0xF87E},
{0xF880,0xF8A0},
{0xF940,0xF97E},
{0xF980,0xF9A0},
{0xFA40,0xFA7E},
{0xFA80,0xFAA0},
{0xFB40,0xFB7E},
{0xFB80,0xFBA0},
{0xFC40,0xFC7E},
{0xFC80,0xFCA0},
{0xFD40,0xFD7E},
{0xFD80,0xFDA0},
{0xFE40,0xFE7E},
{0xFE80,0xFEA0},
以下代码输出GBK比GB2312多出的字符:
1 unsigned short diff_gb2312_gbk_1[][2] = 2 { 3 //GBK-1 special character, 35 characters. 4 {0xA2A1,0xA2AA},//10 5 {0xA6E0,0xA6EB},//12 6 {0xA6EE,0xA6F2},// 5 7 {0xA6F4,0xA6F5},// 2 8 {0xA8BB,0xA8C0},// 6 9 //---------------+-- 10 //--------------//35 11 }; 12 13 unsigned short diff_gb2312_gbk_5[][2] = 14 { 15 //GBK-5 special character, 166 characters. 16 {0xA840,0xA87E},// 63 17 {0xA880,0xA895},// 22 18 {0xA940,0xA957},// 24 19 {0xA959,0xA95A},// 2 20 {0xA95C,0xA95C},// 1 21 {0xA960,0xA97E},// 31 22 {0xA980,0xA996},// 23 23 //--------------//+-- 24 //=-------------//166 25 }; 26 27 unsigned short diff_gb2312_gbk_2[][2] = 28 { 29 //GB2312汉字区 30 //0xD7FE,0xD7FD,0xD7FC,0xD7FB,0xD7FA无定义 31 {0xB0A1,0xF7FE}, 32 }; 33 34 unsigned short diff_gb2312_gbk_3[][2] = 35 { 36 //GBK-3 0xXX7F无定义 37 {0x8140,0xA07E}, 38 {0x8180,0xA0FE}, 39 }; 40 41 unsigned short diff_gb2312_gbk_4[][2] = 42 { 43 //GBK-4 0xXX7F无定义 44 {0xAA40,0xFE7E}, 45 {0xAA80,0xFEA0}, 46 }; 47 48 unsigned short i,j; 49 FILE *fp = fopen("diff_gb2312_gbk.txt","wb"); 50 if(fp == NULL)return 0; 51 52 //fprintf(fp, "GBK.1------------------>\n"); 53 for(i = 0; i < sizeof(diff_gb2312_gbk_1)/sizeof(diff_gb2312_gbk_1[0]); i++) 54 { 55 for(j = diff_gb2312_gbk_1[i][0]; j <= diff_gb2312_gbk_1[i][1]; j++) 56 { 57 fputc(j>>8, fp); 58 fputc(j&0xff,fp); 59 } 60 } 61 //fprintf(fp, "GBK.5------------------>\n"); 62 for(i = 0; i < sizeof(diff_gb2312_gbk_5)/sizeof(diff_gb2312_gbk_5[0]); i++) 63 { 64 for(j = diff_gb2312_gbk_5[i][0]; j <= diff_gb2312_gbk_5[i][1]; j++) 65 { 66 fputc(j>>8, fp); 67 fputc(j&0xff,fp); 68 } 69 } 70 //fprintf(fp, "GBK.3------------------>\n"); 71 for(i = 0; i < sizeof(diff_gb2312_gbk_3)/sizeof(diff_gb2312_gbk_3[0]); i++) 72 { 73 unsigned short k; 74 for(j = ((diff_gb2312_gbk_3[i][0]&0xff00)>>8); j <= ((diff_gb2312_gbk_3[i][1]&0xff00)>>8); j++) 75 { 76 for(k = (diff_gb2312_gbk_3[i][0]&0x00ff); k <= (diff_gb2312_gbk_3[i][1]&0x00ff); k++) 77 { 78 fputc(j, fp); 79 fputc(k, fp); 80 } 81 } 82 } 83 //fprintf(fp, "GBK.4------------------>\n"); 84 for(i = 0; i < sizeof(diff_gb2312_gbk_4)/sizeof(diff_gb2312_gbk_4[0]); i++) 85 { 86 unsigned short k; 87 for(j = ((diff_gb2312_gbk_4[i][0]&0xff00)>>8); j <= ((diff_gb2312_gbk_4[i][1]&0xff00)>>8); j++) 88 { 89 for(k = (diff_gb2312_gbk_4[i][0]&0x00ff); k <= (diff_gb2312_gbk_4[i][1]&0x00ff); k++) 90 { 91 fputc(j, fp); 92 fputc(k, fp); 93 } 94 } 95 } 96 97 if(fp!=NULL) 98 { 99 fclose(fp); 100 fp = NULL; 101 }
GBK