日期:2013-05-10  浏览次数:20538 次

<?
/***********************************************************************
                       Written by caocao
                       caocao@eastday.com
                       http://nethermit.yeah.net
                      
                       简体中文转换为繁体中文类
                       使用方法:
                       $convert=new gtob;
                       $str=$convert->gbtobig5($str);
***********************************************************************/
class gtob
{
    var $data;
    function gbtobig5($str)
    {
        $output="";
        $length=strlen($str);
        for ($i=0;$i<$length;++$i)
        {
            if ($i==$length-1)
            {
                $output.=$str[$i];
                break;
            }
            $code1=ord($str[$i]);
            $code2=ord($str[$i+1]);
            if ($code1>=0x81&&$code1<=0xFE&&$code2>=0x40&&$code2<=0xFE&&$code2!=0x7F)
            {
                $offset=($code1-0x81)*190;
                $offset+=$code2>0x7F?$code2-0x41:$code2-0x40;
                $offset<<=1;
                $output.=substr($this->data, $offset, 2);
                ++$i;
            }
            else
                $output.=$str[$i];
        }
        return $output;
    }
    function gtob()
    {
        $this->data="〖〖〖〖蒑ぁメㄢɑ〖蒔ぅ蒫吮翺〖蒬〖〖葽〖〖〖〖〖あ〖〖〖﹍〖〖〖〖〖〖〖〖秈〖〖〖爱〖〖〖〖訩纓爱睹鼙懿〖〖ㄆ烦ュㄈ翹ㄈ〖ㄉㄊ稧簋鲋栋栋蒚︱さ〖蒵蒅蒮蒰はぶ砂珊ぴぅヴ杀傻刑晒啥环沙苫筛莎ロ┊猩纱ó弯死獺森蔲蔳四璈蔥蔪蔴蔰┟秓ゼ︻蔧┘琇私蔮蔤蔵蔦ホ丝怂颂猭ㄖ思嗣肆ㄞ说硕寺松舜ㄓ朔