<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      簡體中文轉換為繁體中文的PHP函數

      [摘要]感謝網友Keyes提供移植用的Delphi源代碼。其調用方式為txt=gbtobig5(txt)。 (注:源代碼中的include "data_gb.php";這個文件在就是一個數組,在http://caocao.oso.com.cn/data_gb.zip,請編輯下載...
      感謝網友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);
      };
      ?>  

      【本文版權歸作者與奧索網共同擁有,如需轉載,請注明作者及出處】    



      日韩精品一区二区三区高清