无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 3118|回复: 0
打印 上一主题 下一主题

[原创] unifont.hex減肥php腳本

[复制链接]
跳转到指定楼层
1#
发表于 2012-3-25 17:47:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用 CP***.TXT 來限定新的 unifont.hex 所擁有的字數。
CP***.TXT 可在 unicode.org 下載: http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/

用法:
php tbl4slim.php [TXT檔...]
如:
php tbl4slim.php CP936.TXT CP950.TXT

新生成的為 unifont.hex.slim

  1. <?php

  2. $txtfiles = array();
  3. $txtary = array();

  4. $chrs = array();
  5. $newunifonthex = array();

  6. if($_SERVER['argc'] < 2) {
  7.         fwrite(STDERR, "Usage: ".$_SERVER['argv'][0]." {TXT files...}\n");
  8.         exit(2);
  9. }
  10. if(!file_exists('./unifont.hex')) {
  11.         fwrite(STDERR, "Error: unifont.hex not found!\n");
  12.         exit(1);
  13. }

  14. for($i=1;$i<$_SERVER['argc'];++$i) {
  15.         if(!file_exists($_SERVER['argv'][$i])) {
  16.                 fwrite(STDERR, "Warning: ".$_SERVER['argv'][$i]." is not found.\n");
  17.         } else {
  18.                 $txtfiles[] = file($_SERVER['argv'][$i]);
  19.         }
  20. }
  21. foreach($txtfiles as $t) {
  22.         foreach($t as $l) {
  23.                 $txtary = explode("\t",$l);
  24.                 if(isset($txtary[1]) && substr($txtary[1],0,2)=='0x') $chrs[$txtary[1]] = 1;
  25.         }
  26. }

  27. $txtary = file('./unifont.hex');
  28. foreach($txtary as $l) {
  29.         if(isset($chrs['0x'.substr($l,0,4)])) $newunifonthex[] = $l;
  30. }

  31. $fp = fopen('./unifont.hex.slim','wb');
  32. fwrite($fp,implode('',$newunifonthex));
  33. fclose($fp);
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-4-25 01:35

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表