iconv是轉換編碼的,但是在中文轉碼時候出現顯示不全問題。
復制代碼 代碼如下:
iconv("UTF-8","GB2312//IGNORE",$data); 加上//IGNORE,忽略錯誤
或者用mb_convert_encoding()
復制代碼 代碼如下:
<?php
/* 轉換內部編碼為 SJIS */
$str = mb_convert_encoding($str, "SJIS");
/* 將 EUC-JP 轉換成 UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
/* 從 JIS, eucjp-win, sjis-win 中自動檢測編碼,並轉換 str 到 UCS-2LE */
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
/* "auto" 擴展成 "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str = mb_convert_encoding($str, "EUC-JP", "auto");
?>
保險就用mb_conver_encoding