# 將 UTF-8 轉 BIG5:
mb_convert_encoding(要被轉得字串, ‘目標編碼’, ‘原本的編碼’);
$str_big5 = mb_convert_encoding($str_utf8, 'BIG-5', 'UTF-8');
# 將 BIG5 轉 UTF-8:
方法一:
$str_utf8 = mb_convert_encoding($str_big5, 'UTF-8', 'BIG-5');
方法二:
<? function big5_2_utf8($big5str) { $blen = strlen($big5str); $utf8str = ""; for($i=0; $i<$blen; $i++) { $sbit = ord(substr($big5str, $i, 1)); //echo $sbit; //echo "<br>"; if ($sbit < 129) { $utf8str.=substr($big5str,$i,1); } elseif ($sbit > 128 && $sbit < 255) { $new_word = iconv("BIG5", "UTF-8", substr($big5str,$i,2)); $utf8str.=($new_word=="")?"?":$new_word; $i++; } } return $utf8str; } ?>