首 页 | 网页模板 | 教程 | 源码下载 | 书籍下载 | 图片素材 | 字体 | JAVA特效 | FLASH源码 | 软件 | 矢量 | 论坛 | 其它 |
设为主页
加入收藏
联系站长
平面设计 | 网页制作 | 程序编写 | 数 据 库 | 媒体动画 | 网络冲浪 | 服务器相关 |
当前在线
广告:P4服务器电信机房6999/年即送产权 | 疾风下载
网页文字简繁转换函数
2005-11-18 10:15:18  作者:模板天下收集整理  来源:未知 网友评论 0 条 论坛
  <?
function isgb($code) { if (strlen($code)>=2)
{
$code=strtok($code,"");
if ((
ord($code[0]) < 161)||(ord($code[0]) >= 247))
{
return (
0);
}
else
{
if ((
ord($code[1]) <= 161)||(ord($code[1]) >= 254))
{
return (
0);
}
else
{
return (
1);
}
}
}
else
{
return (
1);
}
}

function
gboffset($code)
{
if (
strlen($code) >= 2)
{
$code=strtok($code,"");
return ((
ord($code[0]) - 161) * 94 + (ord($code[1]) - 161));
}
else
{
return(-
1);
}
}

function
wordtostring($code)
{
return (
chr(hexdec(substr($code,0,2))).chr(hexdec(substr($code,2,2))));
}

function
gbtobig5($code)
{
include
"data_gb.php";
$output="";
$length=strlen($code);
$code=strtok($code,"");
$idx=0;
while (
$idx < $length)
{
$tmpStr=$code[$idx].$code[$idx+1];

if (
isgb($tmpStr))
{
$offset=gboffset($tmpStr);
if ((
$offset >= 0)||($offset <= 8177))
{
$output.=wordtostring($gborder[$offset]);
$idx++;
}
else
{
$output.= $code[$idx];
}
}
else
{
$output.= $code[$idx];
}
$idx++;
}
return (
$output);
};
?>




使用方法:

1. 将以上代码另存为gbtobig5.php

2. 在需要的页面引入gbtobig5.php


3. 对目标字段套用函数,实现格式化输出
?>
共分1页  [1] 
>> 相关文章

关于网站 | 客服中心 | 服务条款 | 友情链接 | 广告联系 | 本站历程 | 网站导航

吉ICP备05000107号