本帖最后由 hotpower 于 2023-9-23 10:35 编辑
菜农电子淘宝:https://hotcomlock.taobao.com/ 准备出书:http://hotcomlock.com/hotcomlock.html
- HotCode汉字编码(V1.0)是菜农对UniCode编码(V5.0)的汉字简化版本:
- 1.用0080-00ff替换2580-25ff方块元素几何图形。
- 2.用f900-faff替换2c00-2dff格拉哥里字母等。
- 3.用fe30-fe4f替换9fc0-9fdf未定义。
- 4.用ff00-ffff替换2800-28ff盲文点字模型。
- HotCode选中unicode2000-9fff为编码范围,
- 然后加6000,使HotCode编码范围为8000-ffff,ascii码为00-7f。
- HotCode编码汉字为两字节,字符为单字节。
- function HotCodeToHex(hotcodestr) {
- var str,ptr,hexstr;
- var i, num;
- hexstr = "";
- str = hotcodestr;
- i = 0;
- for(i = 0;i < str.length;i ++) {
- num = str.charCodeAt(i);
- if(num < 0x80) {//字符,.[]-+
- hexstr += inttohex(num, 2);
- }
- else if(num < 0x100){
- num -= (0x0080 - 0x2580);//0x80-0x80+2580
- num += 0x6000;
- hexstr += inttohex(num, 4);
- }
- else {//汉字
- if(num >= 0xff00) {//全角ascii,全角中英文标点等
- num -= (0xff00 - 0x2800);
- }
- else if (num >= 0xfe30 && num <= 0xfe4f) {
- num -= (0xfe30 - 0x9fc0);
- }
- else if (num >= 0xf900 && num <= 0xfaff) {
- num -= (0xf900 - 0x2c00);
- }
- else if (num >= 0x2000 && num <= 0x9fff) {
- }
- else {
- num = 0x3000;//空格
- }
- num += 0x6000;
- ptr = inttohex(num, 4);
- hexstr += ptr;
- }
- }
- return hexstr;
- }

|