Gb2312 and utf8 Conversion

Source: Internet
Author: User

Swap gb2312 with UTF-8 in PHP.

Gb2312 UTF-8

Iconv("Gb2312", "UTF-8", $ text)

UTF-8-gb2312

Iconv("UTF-8", "gb2312", $ text)

 

ConvThe function converts the captured UTF-8 encoded page to gb2312.IconvThe function will reduce the amount of data captured by Code Conversion for no reason. Check the information on the Internet to know that this isIconvA Function Bug.IconvAn error occurs when converting the character "-" To gb2312.

The solution is simple, that is, add "// ignore" after the code to be convertedIconvThe second parameter of the function is as follows:
Reference content is as follows:

Iconv("UTF-8", "gb2312 // ignore", $ data)

Ignore indicates that the conversion error is ignored. Without the ignore parameter, all strings after this character cannot be saved.

 

IconvNoPHPIs also the default function installed by default. Installation is required.

Author: Sjolzy | Google + Address: Http://sjolzy.cn/gb2312-and-utf8-conversion.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.