用PHP转换码表

用PHP转换码表
—————————————————————-
在繁体WINDOWS下用输入法生成器把码表转出来,格式如下:

[Description]
Name=念青五筆
MaxCodes=4
MaxElement=1
UsedCodes=abcdefghijklmnopqrstuvwxy
WildChar=z
NumRules=3
[Rule]
ca4=p11+p21+p31+n11
ce2=p11+p12+p21+p22
ce3=p11+p21+p31+p32
[Text]
工a
式aa
菚aaa
恭恭敬敬aaaa
工期aaad
葡萄牙aaah
……………………
—————————————————————
小企鹅中文输入法(FCITX)的码表格式如下:

键码=abcdefghijklmnopqrstuvwxy
码长=4
[组词规则]
e2=p11+p12+p21+p22
e3=p11+p21+p31+p32
a4=p11+p21+p31+n11
[数据]
a 工
aa 式
aaaa 恭恭敬敬
aaad 工期
aaah 葡萄牙
aaal 花花世界
aaar 工匠
aaau 工薪
aabb 式子
……………………
—————————————————————
PHP代码:

<?php
$file="wb.txt";
$file_array=file($file);
for ($i=0;$i<count($file_array);$i++){
$new_line=substr($file_array[$i],0,100); //本想去掉最后的换行符的,不知道有多长。
 

for ($j=0;$j<strlen($file_array[$i]);$j++) {
if (ereg(“^[a-z]“,substr($new_line,$j,1))) break;
}
$a3=substr($new_line,0,$j).” “.substr($new_line,$j,100);
//$a3=substr($new_line,$j,100).” “.substr($new_line,0,$j);//前后调转,没有搞好,换行的问题

$handle = fopen (“linux_wb.txt”, “a”);
fwrite($handle,$a3);
}
fclose($handle);
?>

This entry was posted in Program, 网摘. Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>