硬件学院 | 网络学院 | 游戏秘籍 | 求职技巧 | 企业管理 | 软件资讯 | IT导购 | 软件下载 | 源码下载
软件学院 | 安全资讯 | 图形图象 | 网络营销 | 电子商务 | 硬件资讯 | IT生活 | 教程下载 | 电影娱乐
网站首页    个人求职    单位招聘    高校联盟    猎头服务    培训服务    资讯中心    IT论坛
让每一个热爱IT的人都找到一份满意的工作!
文章搜索:
 您的位置首页->-> 软件学院-> PHP技术-> 简体中文转换为繁体中文的PHP函数
简体中文转换为繁体中文的PHP函数
作者:中国资讯网 来源:zixuen.com 加入时间:2005-5-12 www.cnitrc.com
感谢网友Keyes提供移植用的Delphi源代码。其调用方式为$txt=gbtobig5($txt)。
(注:源代码中的include "data_gb.php";这个文件在就是一个数组,在http://caocao.oso.com.cn/data_gb.zip,请编辑下载到oso上,做一个链接,因为这个文件我过几天就要删除了。)

<?
/***********************************************************************
Written by caocao
caocao@eastday.com
http://caocao.oso.com.cn

With the help of Keyes
Keyes2000@263.net
http://my-wjl.scu.edu.cn/~Keyes
***********************************************************************/
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);
};
?>



  相关文章:
PHP技术
ASP技术
PHP技术
JSP技术
.NET技术
服务器技术
数据库技术
其它类
工具软件
办公软件
本类阅读TOP10
 
关于我们   |   服务声明   |   使用帮助   |   广告合作   |   网站地图   |   友情链接   |   加盟合作   |   联系我们
Copyright © 2006 cnitrc.com Inc. All Rights Reserved. 浙ICP备05074295号
中国IT人才网 版权所有 网络实名:中国IT人才
未经书面授权严禁转载和复制本站的任何招聘信息和文章