Solution to the problem of character truncation when the iconv function transcodes in PHP, iconv truncation
iconv converts the encoding, but there is an incomplete display problem when transcoding Chinese.
Copy code The code is as follows:
iconv("UTF-8","GB2312//IGNORE",$data); Add //IGNORE and ignore errors
Or use mb_convert_encoding()
Copy code The code is as follows:
/* Convert internal encoding to SJIS */
$str = mb_convert_encoding($str, "SJIS");
/* Convert EUC-JP to UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
/* Automatically detect encoding from JIS, eucjp-win, sjis-win and convert str to UCS-2LE */
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
/* "auto" expands to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str = mb_convert_encoding($str, "EUC-JP", "auto");
?>
Use mb_conver_encoding for insurance
http://www.bkjia.com/PHPjc/945712.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/945712.htmlTechArticleSolution to the problem of character truncation when the iconv function transcodes in PHP. iconv truncates iconv to convert the encoding, but when There is an issue with incomplete display when transcoding Chinese. Copy the code The code is as follows...