The error encountered by the Iconv () function of PHP: detected an illegal character in input string ...

Source: Internet
Author: User

Using Iconv () to convert a character that is not supported by an output character encoding, such as Iconv (' UTF-8 ', ' GB2312 ', ' embarrassing '), you may encounter such error prompts:

Notice:iconv () [Function.iconv]: detected a illegal character in input string ...

Because GB2312 is simplified Chinese and does not support more complex Chinese characters such as "embarrassing" and some special characters, this will certainly be an error, and there are two ways to solve this problem :

1. enlarge the range of the output character encoding, such as Iconv (' UTF-8 ', ' GBK ', ' the ', '), it can be output correctly, because the GBK supports a wider range of characters;

2. Add "//ignore" to the output character-encoded string, such as Iconv (' UTF-8 ', ' gb2312//ignore ', ' ' embarrassing '), which in fact ignores characters that cannot be converted, avoids errors but does not output correctly ( That is, blank, output).

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.