Chinese garbled text-phppreg_match_all garbled text when handling Chinese characters

Source: Internet
Author: User
When phppreg_match_all is used to process Chinese characters, garbled characters are modified to UTF-8, but some matching results may contain garbled characters such as php preg_match_all.

The encoding is changed to UTF-8, but some matching results may contain garbled characters.

Reply content:

Php preg_match_all garbled characters when processing Chinese characters

The encoding is changed to UTF-8, but some matching results may contain garbled characters.

To support I18N, we recommend that you use mb_ereg _ * series functions. For more information, see Manual in PHP.

When we capture a remote webpage, garbled code may occur due to encoding problems and transcoding is required.

$ File = file_get_contents ("http://blog.xbmu.info"); // remotely capture preg_match_all (); // extract information // select transcoding as needed: $ str2 = iconv ("UTF-8 ", "gb2312 // IGNORE", $ str2); // Convert utf to gb2312 $ str2 = iconv ("gb2312", "UTF-8 // IGNORE", $ str2 ); // Convert gb2312 to utf

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.