Home  >  Article  >  Backend Development  >  iconv() [function.iconv]: Detected an illegal character in_PHP教程

iconv() [function.iconv]: Detected an illegal character in_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:57:091014browse

This article will introduce to you several solutions to the iconv() [function.iconv]: Detected an illegal character in error. Friends who need to know more can refer to it.

When using the iconv function to convert gb2312 to utf-8, why are there problems with some Chinese characters? Characters like "??quot; will be prompted as follows:
Notice: iconv() [function.iconv]: Detected an illegal character in input string

Solution:

Php code
The code is as follows
 代码如下 复制代码

iconv('UTF-8', 'GB2312//IGNORE', '??')
iconv('UTF-8', 'GBK', '??')

Copy code

iconv('UTF-8', 'GB2312//IGNORE', '??')

iconv('UTF-8', 'GBK', '??')


Either the encoding is wrong, or the suppressor @ is added

We can also use other methods

Make a GBK To UTF-8
 代码如下 复制代码

header("content-Type: text/html; charset=Utf-8");
echo mb_convert_encoding("???S我的友仔", "UTF-8", "GBK");
?>



Detailed explanation of how to use mb_convert_encoding()

 代码如下 复制代码
header("content-Type: text/html; charset=big5");
echo mb_convert_encoding("你是我的朋友", "big5", "GB2312");
?> 
The code is as follows
Copy code

header("content-Type: text/html; charset=Utf-8"); echo mb_convert_encoding("???SMy friend", "UTF-8", "GBK"); ?> Another GB2312 To Big5
The code is as follows Copy code
header("content-Type: text/html; charset=big5");
echo mb_convert_encoding("You are my friend", "big5", "GB2312");
?> http://www.bkjia.com/PHPjc/632119.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632119.htmlTechArticleThis article will introduce iconv() [function.iconv]: Detected an illegal character in several errors Friends who need to know the solution can refer to it. Use iconv function to convert gb2312 to...
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