以下讨论以gb2312字库为前提。
汉字占两个字节高字节 - 0xA0 = 区码低字节 - 0xA0 = 位码汉字: "胡",的两个字节为[186, 250] = 186 * 256 + 250 = 47866186-->0xBA - 0xA0 = 1A = 26(区)250-->0xFA - 0xA0 = 5A = 90(位)得到,汉字"胡"的区位码为:2690
=========================================================由于gb2312汉字库中的3755个一级汉字是以拼音排序的,据此标识各拼音首字母开始于哪个区位码(数值),也就能根据该汉字得到其拼音首字母了。
A:啊(1601) = (0x10 + 0xA0) * 256 + (0x01 + 0xA0) = 45217B:芭(1637) = (0x10 + 0xA0) * 256 + (0x37 + 0xA0) = 45253C:擦(1833) = (0x12 + 0xA0) * 256 + (0x21 + 0xA0) = 45761D:搭(2078) = (0x14 + 0xA0) * 256 + (0x4E + 0xA0) = 46318E:蛾(2274) = (0x16 + 0xA0) * 256 + (0x4A + 0xA0) = 46826F:发(2302) = (0x17 + 0xA0) * 256 + (0x02 + 0xA0) = 47010G:噶(2433) = (0x18 + 0xA0) * 256 + (0x21 + 0xA0) = 47297H:哈(2594) = (0x19 + 0xA0) * 256 + (0x5E + 0xA0) = 47614I:J:击(2787) = (0x1B + 0xA0) * 256 + (0x57 + 0xA0) = 48119K:喀(3106) = (0x1F + 0xA0) * 256 + (0x06 + 0xA0) = 49062L:垃(3212) = (0x20 + 0xA0) * 256 + (0x0C + 0xA0) = 49324M:妈(3472) = (0x22 + 0xA0) * 256 + (0x48 + 0xA0) = 49896N:拿(3635) = (0x24 + 0xA0) * 256 + (0x23 + 0xA0) = 50371O:哦(3722) = (0x25 + 0xA0) * 256 + (0x16 + 0xA0) = 50614P:啪(3730) = (0x25 + 0xA0) * 256 + (0x1E + 0xA0) = 50622Q:期(3858) = (0x26 + 0xA0) * 256 + (0x3A + 0xA0) = 50906R:然(4027) = (0x28 + 0xA0) * 256 + (0x1B + 0xA0) = 51387S:撒(4086) = (0x28 + 0xA0) * 256 + (0x56 + 0xA0) = 51446T:塌(4390) = (0x2B + 0xA0) * 256 + (0x5A + 0xA0) = 52218U:V:W:挖(4558) = (0x2D + 0xA0) * 256 + (0x3A + 0xA0) = 52698X:昔(4684) = (0x2E + 0xA0) * 256 + (0x54 + 0xA0) = 52980Y:压(4925) = (0x31 + 0xA0) * 256 + (0x19 + 0xA0) = 53689Z:匝(5249) = (0x34 + 0xA0) * 256 + (0x31 + 0xA0) = 54481结束(5590) = (0x37 + 0xA0) * 256 + (0x5A + 0xA0) = 55290=========================================================
转载于:https://www.cnblogs.com/roogeer/archive/2009/12/03/1616595.html
相关资源:汉字机内码 机内码 区位码 国标码的区别