php专区

 首页 > php专区 > PHP应用 > php函数大全 > 简体中文转换为繁体中文的PHP函数

简体中文转换为繁体中文的PHP函数

分享到:
【字体:
导读:
          感谢网友Keyes提供移植用的Delphi源代码。其调用方式为$txt=gbtobig5($txt)。(注:源代码中的include "data_gb php ";这个文件在就是一个数组,在http: caocao oso com cn data_gb zip,请编辑下载到oso上,做

  感谢网友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中的日期处理
  我正打算用PHP编写一种帮助处理系统。我发现我必须知道处理完最后一位客户的问题后已经过去了多长时间?当我过去用ASP时解决这个问题相当简单,ASP有相应的函数DateDiff可以给出两个日期间间隔多少月、多少天和多少秒。当我搜寻完PHP手册后我发现PHP并没有类似的函数。 本文包含以下内容: 1、 得到目前的日期和时间...
PHP中的日期及时间
  PHP有很多便于使用的函数以显示及处理日期。 要以某种特定格式显示日期或时间,可使用date()函数。它有两个参数:如何显示日期的格式以及代表你所要显示日期的时间戳。这个时间戳必须是先前所提到的从 1970 年起算的总秒数(如果你要使用当前时间可使用time()函数,此函数会返回“现在”的时间戳)。date() 有很多格式...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……