| function big5togb($code) { //参数$code是big5码的字符串 include "data_big5.php"; //包含big5数据的文件 $output=""; $length=strlen($code); //取得字符串长度 $code=strtok($code,""); $idx=0; while ($idx < $length) { $tmpStr=$code[$idx].$code[$idx+1]; if (isbig5($tmpStr)) //判断是否big5码 { ……//如果是big5码则进行转换后输出 } else { $output.= $code[$idx]; //如果不是big5码则直接输出 } $idx++; } return ($output); } |
| function gbtobig5($code) { include "data_gb.php"; //包含有gb码的数据文件 $output=""; $length=strlen($code); $code=strtok($code,""); $idx=0; while ($idx < $length) { $tmpStr=$code[$idx].$code[$idx+1]; if (isgb($tmpStr)) //判断是否gb码 { ……//如果是gb码转换后输出 } else { $output.= $code[$idx]; //不是gb码则直接输出 } $idx++; } return ($output); } |
用户评论