Home > Backend Development > PHP Tutorial > Solution to the problem of character truncation when the iconv function transcodes in PHP, iconv truncation_PHP tutorial

Solution to the problem of character truncation when the iconv function transcodes in PHP, iconv truncation_PHP tutorial

WBOY
Release: 2016-07-13 10:09:25
Original
987 people have browsed it

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

www.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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template