[独创算法] HotCRC内的HexToHotCode()源码(菜农自创万国字符编码)

[复制链接]
 楼主| hotpower 发表于 2023-9-23 10:26 | 显示全部楼层 |阅读模式
本帖最后由 hotpower 于 2023-9-23 10:37 编辑

菜农电子淘宝:https://hotcomlock.taobao.com/ 准备出书:http://hotcomlock.com/hotcomlock.html
  1. HotCode汉字编码(V1.0)是菜农对UniCode编码(V5.0)的汉字简化版本:
  2. 1.用0080-00ff替换2580-25ff方块元素几何图形。
  3. 2.用f900-faff替换2c00-2dff格拉哥里字母等。
  4. 3.用fe30-fe4f替换9fc0-9fdf未定义。
  5. 4.用ff00-ffff替换2800-28ff盲文点字模型。
  6. HotCode选中unicode2000-9fff为编码范围,
  7. 然后加6000,使HotCode编码范围为8000-ffff,ascii码为00-7f。
  8. HotCode编码汉字为两字节,字符为单字节。
  1.     function HexToHotCode(hexstr) {
  2.         var str,hotcodestr;
  3.         var i, num;
  4.         hotcodestr = "";
  5.         i = 0;
  6.         while(i < hexstr.length) {
  7.             str        = hexstr.substr(i, 2);
  8.             num = hextoint(str);
  9.             if (num < 0x80) {//
  10.                                 if(num == 0) break;//0字符不解码
  11.                 hotcodestr += String.fromCharCode(num);
  12.                 i += 2;
  13.             }
  14.             else {
  15.                 str        = hexstr.substr(i, 4);
  16.                 num = hextoint(str);
  17.                 num -= 0x6000;
  18.                 if (num > 0x2580 && num <= 0x25ff) {
  19.                     num -= (0x2580 - 0x0080);
  20.                 }
  21.                 else {
  22.                     if (num > 0x2800 && num <= 0x28ff) {
  23.                         num -= (0x2800 - 0xff00);
  24.                     }
  25.                     else if (num > 0x9fc0 && num <= 0x9fdf) {
  26.                         num -= (0x9fc0 - 0xfe30);
  27.                     }
  28.                     else if (num > 0x2c00 && num <= 0x2dff) {
  29.                         num -= (0x2c00 - 0xf900);
  30.                     }
  31.                 }
  32.                 hotcodestr += String.fromCharCode(num);
  33.                 i += 4;
  34.             }
  35.         }
  36.         return hotcodestr;
  37.     }

懒癌晚期患者 发表于 2025-3-31 09:12 | 显示全部楼层
这个HotCode编码方式挺有意思的,感觉像是对Unicode的一种优化。不过,这种编码方式在实际应用中会不会和现有的编码标准产生冲突呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:[url=http://www.21ic.com/tools/HotWC3_V1.23.html]

1460

主题

21619

帖子

508

粉丝
快速回复 在线客服 返回列表 返回顶部