Home > Backend Development > PHP Tutorial > Bug solution for converting PHP iconv function to gb2312_PHP tutorial

Bug solution for converting PHP iconv function to gb2312_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:44:11
Original
757 people have browsed it

iconv( "UTF-8", "gb2312//IGNORE" , $FormValues['a'])

ignore means ignoring errors during conversion. It was found that iconv was converting the character "—" to gb2312 An error will occur. If there is no ignore parameter, all strings following this character cannot be saved.

In addition, mb_convert_encoding does not have this bug, so the best way to write it is:

mb_convert_encoding($FormValues['a'], "gb2312", "UTF-8");

But you need to enable the mbstring extension library first.

You can also set the collation of the mysql database to utf-8 and not use it for conversion.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320595.htmlTechArticleiconv( "UTF-8", "gb2312//IGNORE" , $FormValues['a']) ignore It means to ignore errors during conversion. It is found that iconv will make an error when converting the character "—" to gb2312. If there is no ignore parameter, so...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template