CP936 to UTF-8, cp936 to UTF-8

Source: Internet
Author: User

CP936 to UTF-8, cp936 to UTF-8

Recently I wrote a script to capture most of the content normally, but a small part of it is garbled.

 

Check the character encoding and the result is CP936.

Mb_detect_encoding ($ str, 'gbk, gb2312, GB18030, ISO-8859-1, ASCII, UTF-8 ', true)

Try to convert the encoding, but the result is still garbled

Mb_convert_encoding ($ str, 'utf-8', 'cp936 '); the number of blind cats in the middle of the year is 70, and the number of cats in the middle of the day is 7. lu is busy

Finally, we found that transcoding can be performed.

Iconv ('utf-8', 'latin1', $ str );
Iconv ('utf-8', 'latin1 // IGNORE ', $ str );

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.