选择显示字体大小

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


前几天我在oso论坛上问有没有这个源程序,没人回复。终于下定决心移植一个这样的函数,感谢网友keyes提供移植用的delphi源代码。其调用方式为$txt=big5togb($txt)。
(注:源代码中的include "data_big5.php";这个文件在就是一个数组,在http://caocao.oso.com.cn/data_big5.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 isbig5(&#36;code)
{
if (strlen(&#36;code)>=2)
{
&#36;code=strtok(&#36;code,&quot;&quot;);

if (ord(&#36;code[0]) < 161)
{
return (0);
}
else
{
if (((ord(&#36;code[1]) >= 64)&&(ord(&#36;code[1]) <= 126))((ord(&#36;code[1]) >= 161)&&(ord(&#36;code[1]) <= 254)))
{
return (1);
}
else
{
return (0);
}
}
}
else
{
return (0);
}
}

function big5offset(&#36;code)
{
if (strlen(&#36;code) >= 2)
{
&#36;code=strtok(&#36;code,&quot;&quot;);
if ((ord(&#36;code[1]) >= 64)&&(ord(&#36;code[1]) <= 126))
{
return ((ord(&#36;code[0]) - 161) * 157 + (ord(&#36;code[1]) - 64));
}
if ((ord(&#36;code[1]) >= 161)&&(ord(&#36;code[1]) <= 254))
{
return ((ord(&#36;code[0]) - 161) * 157 + 63 + (ord(&#36;code[1]) - 161));
}
}
return (-1);
}

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

function big5togb(&#36;code)
{
include &quot;data_big5.php&quot;;
&#36;output=&quot;&quot;;
&#36;length=strlen(&#36;code);
&#36;code=strtok(&#36;code,&quot;&quot;);
&#36;idx=0;
while (&#36;idx < &#36;length)
{
&#36;tmpstr=&#36;code[&#36;idx].&#36;code[&#36;idx+1];

if (isbig5(&#36;tmpstr))
{
&#36;offset=big5offset(&#36;tmpstr);
if ((&#36;offset >= 0)(&#36;offset <= 14757))
{
&#36;output.=wordtostring(&#36;big5order[&#36;offset]);
&#36;idx++;
}
else
{
&#36;output.= &#36;code[&#36;idx];
}
}
else
{
&#36;output.= &#36;code[&#36;idx];
}
&#36;idx++;
}
return (&#36;output);
}
?>

  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons