Italic gb2312 PHP iconv function to gb2312 bug solution

WBOY
Release: 2016-07-29 08:40:51
Original
952 people have browsed it

iconv( "UTF-8", "gb2312//IGNORE" , $FormValues['a'])
ignore means to ignore errors during conversion. It is found that iconv will make an error when converting the character "—" to gb2312. If not 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 it will not be used for conversion.

The above introduces the bug solution for converting the regular script gb2312 PHP iconv function to gb2312, including the content of regular script gb2312. I hope it will be helpful to friends who are interested in PHP tutorials.

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