Home  >  Article  >  Backend Development  >  PHP错误:iconv Detected an illegal character

PHP错误:iconv Detected an illegal character

WBOY
WBOYOriginal
2016-07-29 09:14:411086browse

When using the iconv function to convert Chinese character strings in php, the following error is prompted:
Notice: iconv() [function.iconv]: Detected an illegal character in input string in a.php on line 796

Error The statement is as follows:
iconv("GB2312","UTF-8",$a);

The solution is to change GB2312 to GBK:
iconv("GBK","UTF -8",$a);

The reason for this error is that characters outside the range of GB2312 appear in the string $a, so the iconv function has an error. Because the range of gbk is wider than that of gb3212, and because the encoding of the two formats is the same but the range is different, using a wide range of gbk to define the string can contain more characters, so the conversion is successful!

The above introduces the PHP error: iconv Detected an illegal character, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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