PHP solves the problem of utf-8 and gb2312 encoding conversion_PHP tutorial

WBOY
Release: 2016-07-21 15:39:43
Original
1050 people have browsed it

Finally, Huangtian paid off and I found the answer.

This is how it is used on the Internet

Copy the code The code is as follows:

$content = iconv("utf-8","gb2312",$content);


This is actually correct. It looks like it is indeed converting utf-8 to gb2312. But in actual operation, it often ends in failure. What is the reason?

The reason is actually very simple, because any function will have an execution error, and unfortunately iconv(); will eventually cause an error. Now give you the correct answer.

The real answer is this

Copy code The code is as follows:

$content = iconv("utf-8","gb2312//IGNORE",$content);


It’s very simple, just add //IGNORE after it, just add this ICONV() function ignores errors and continues execution.

Similarly, to change gb2312 to utf-8, just write $content = iconv("gb2312","utf-8//IGNORE",$content);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321499.htmlTechArticleFinally, Huangtian paid off and I found the answer. The copy code used on the Internet is as follows: $content = iconv("utf-8","gb2312",$content); This is actually the same as...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!