header("Content-Type: text/html; charset=big5");
$content='國際友誼賽';
echo unicode_to_big5($content);function unicode_to_big5($str)
{
preg_match_all("/(\d{2,5})/", $str,$a);
$a = $a[0];
foreach ($a as $dec){
if ($dec < 128) {
$utf .= chr($dec);
} else if ($dec < 2048) {
$utf .= chr(192 + (($dec - ($dec % 64)) / 64));
$utf .= chr(128 + ($dec % 64));
} else {
$utf .= chr(224 + (($dec - ($dec % 4096)) / 4096));
$utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
$utf .= chr(128 + ($dec % 64));
}
}
$str=$utf;
$str=iconv( "UTF-8", "BIG5",$str);
//$str=mb_convert_encoding( $str, "BIG5","UTF-8"); //也可以
return $str;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货