This article describes how to solve the problem of truncation characters during iconv function transcoding in PHP. the solution provided in this article is to use mb_convert_encoding instead of iconv, if you need iconv, refer to iconv conversion encoding. However, the iconv is not fully displayed during Chinese transcoding.
The code is as follows:
Iconv ("UTF-8", "GB2312 // IGNORE", $ data); with // IGNORE, IGNORE errors
Or use mb_convert_encoding ()
The code is as follows:
<? Php
/* Convert the internal code to SJIS */
$ Str = mb_convert_encoding ($ str, "SJIS ");
/* Convert EUC-JP to UTF-7 */
$ Str = mb_convert_encoding ($ str, "UTF-7", "EUC-JP ");
/* Automatically detects encoding from JIS, eucjp-win, sjis-win, and converts str to UCS-2LE */
$ Str = mb_convert_encoding ($ str, "UCS-2LE", "JIS, eucjp-win, sjis-win ");
/* "Auto" extended to "ASCII, JIS, UTF-8, EUC-JP, SJIS "*/
$ Str = mb_convert_encoding ($ str, "EUC-JP", "auto ");
?>
Use mb_conver_encoding for insurance