function utf8_2_big5($utf8_str) {
$i=0;
$len = strlen($utf8_str);
$big5_str="";
for ($i=0;$i
$sbit = ord(substr($utf8_str,$i,1));
if ($sbit < 128) {
$big5_str.=substr($utf8_str,$i,1);
} else if($sbit > 191 && $sbit < 224) {
$new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,2));
$big5_str.=($new_word=="")?(mb_convert_encoding(substr($utf8_str,$i,3), 'HTML-ENTITIES', 'UTF-8')):$new_word;
$i++;
} else if($sbit > 223 && $sbit < 240) {
$new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,3));
$big5_str.=($new_word=="")?(mb_convert_encoding(substr($utf8_str,$i,3), 'HTML-ENTITIES', 'UTF-8')):$new_word;
$i+=2;
} else if($sbit > 239 && $sbit < 248) {
$new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,4));
$big5_str.=($new_word=="")?(mb_convert_encoding(substr($utf8_str,$i,3), 'HTML-ENTITIES', 'UTF-8')):$new_word;
$i+=3;
}
}
return $big5_str;
}