2007年11月9日 星期五

檢查字串為繁體的函數

function isBig5($c="")
{
//is_big5
if($c=="")return false; //空字串
$len_of_c=strlen($c);

if($len_of_c%2==1)return false; //長度非偶數
for($ii=0;$ii<$len_of_c;$ii+=2){
$chk_c=substr($c,$ii,2);
$bc = hexdec(bin2hex($chk_c));
if(($bc>=0xa440 && $bc<= 0xc67e) || ($bc>=0xc940 && $bc<= 0xf9fe) || ($bc>=0xa140 && $bc<= 0xa3fe) ||
($bc>=0xc6a1 && $bc<= 0xc8fe))$nothing=true;
else return false;
}

return true;

}
?>

沒有留言: