導讀 跟大家講解下有關classified post 簡繁體轉換的class,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說classified post
跟大家講解下有關classified post 簡繁體轉換的class,相信小伙伴們對這個話題應該也很關注吧,現在就為小伙伴們說說classified post 簡繁體轉換的class,小編也收集到了有關classified post 簡繁體轉換的class的相關資料,希望大家看到了會喜歡。
這是以class包裝好的簡繁體轉換的class, 另外需要兩個table檔: 1. http://www.jerry.com.tw/php/big5.map 2. http://www.jerry.com.tw/php/gb.map 程式如下: CCharset.php3 big5轉GB for string // function Gb_Big5($str) => GB轉Big5 for string //===================================================== class CCharset { var $gb_map="gb.map"; //如果要放到別的路徑,要加上完整路徑 var $big5_map="big5.map"; //例如 ="/home/table/gb.map var $dep_char = 127; //----------------------------------------------------------------- function cbig5_gb($str,$fd) { $c=ord(substr($str,0,1)); $x=ord(substr($str,1,1)); $address=(($c-160)*510)+($x-1)*2; fseek($fd, $address); $hi=fgetc($fd); $lo=fgetc($fd); return"$hi$lo"; } function cgb_big5($str,$fd) { $c=ord(substr($str,0,1)); $x=ord(substr($str,1,1)); $address=(($c-160)*510)+($x-1)*2; fseek($fd, $address); $hi=fgetc($fd); $lo=fgetc($fd); return"$hi$lo"; } //----------------------------------------------------------------- function Big5_Gb($str) { $fd = fopen ($this->gb_map,"r"); $str=str_replace("charset=big5","charset=gb2312", $str); $outstr=""; for($i=0;$i $this->dep_char) { $outstr.=$this->cbig5_gb(substr($str,$i,2),$fd); $i++; } else { $outstr.=substr($str,$i,1); } } fclose ($fd); return $outstr; } //----------------------------------------------------------------- function Gb_Big5($str) { $fd = fopen ($this->big5_map,"r"); $str=str_replace("charset=gb2312","charset=big5", $str); $outstr=""; for($i=0;$i $this->dep_char) { $outstr.=$this->cgb_big5(substr($str,$i,2),$fd); $i++; } else { $outstr.=substr($str,$i,1); } } fclose ($fd); return $outstr; } } ?> =================================================================== 使用範例: Big5_Gb($big5); echo $tgb; //===> $tgb為轉換好的gb碼字串 $tbig5=$obj->Gb_Big5($tgb); echo $tbig5; // 又被轉回來了: big5 //====================================== ?>", $fcontents); $code=new CCharset; $gb=$code->Big5_Gb($fcontents); echo $gb; ?> 範例: $val"; $url.="&".$key."=".urlencode($val); } $fcontents = join( '', file("$url") ); $code=new CCharset; $fc //echo"轉換過的 $CHAR_GB"; echo $fcontents; exit; } //} else setcookie("CHAR_GB",0,time()+ 31536000); echo""; include("hows.php3"); echo""; echo""; echo"echo""; echo"




以上就介紹了classified post 簡繁體轉換的class,包括了classified post方面的內容,希望對PHP教程有興趣的朋友有所幫助。
來源:php中文網