PHPiconv solves UTF-8 and gb2312 encoding conversion problem _ PHP Tutorial

Source: Internet
Author: User
PHPiconv solves UTF-8 and gb2312 encoding conversion problems. At last, the Emperor did not lose heart, but the answer still found me. The code for copying code on the internet is as follows: $ contenticonv (UTF-8, gb2312, $ content); in fact, the answer still gives me the answer.

This is the case on the Internet.

The code is as follows:

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



This is actually the opposite. it seems that UTF-8 is indeed converted to gb2312, but the actual operation is often ended in failure. why?

The reason is actually very simple, because any function is executed incorrectly, and unfortunately iconv (); finally, an error occurs. Now let's give you the correct answer.

The real answer is:

The code is as follows:

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



Simply add a // IGNORE to the end, and the ICONV () function can IGNORE the error and continue execution.

Similarly, to replace gb2312 with UTF-8, you only need to write $ content = iconv ("gb2312", "UTF-8 // IGNORE", $ content );.

Bytes. The code used on the internet is as follows: $ content = iconv ("UTF-8", "gb2312", $ content); this is actually true...

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.