PHP transcoding problems, how to elegantly convert UTF-8 into GBK?

Source: Internet
Author: User
Data is transferred at business time and needs to be transcoded, from UTF-8 to GBK. PHP functions are relatively mentally retarded, leading to a large amount of data conversion failures. Is there a better transcoding method that can automatically ignore the codes in the content that cannot be converted successfully, so don't lose data? Data is transferred at business time and needs to be transcoded, from UTF-8 to GBK. PHP functions are relatively mentally retarded, leading to a large amount of data conversion failures. Is there a better transcoding method that can automatically ignore the codes in the content that cannot be converted successfully, so don't lose data?

Reply content:

Data is transferred at business time and needs to be transcoded, from UTF-8 to GBK. PHP functions are relatively mentally retarded, leading to a large amount of data conversion failures. Is there a better transcoding method that can automatically ignore the codes in the content that cannot be converted successfully, so don't lose data?

Http://php.net/manual/en/function.iconv.php

Use// IGNORETo ignore words that cannot be converted

PhpIconv ("UTF-8", "GBK // IGNORE", $ text );

The specified IGNORE mentioned above is a little bit, but there is still a BUG in this product, which is simply written as follows:
Http://www.yundaiwei.com/post/375.html

There is almost no introduction to this BUG on the Chinese website. It is mentioned on the English website, but it is not clear, and we do not know which or which versions will have bugs. In short, compile the latest iconv during Environment installation.

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.