The php function mb_detect_encoding automatically identifies the encoding and converts it to utf8.

Source: Internet
Author: User
Php has an automatic identification function mb_detect_encoding (), the following code detects the article encoding and automatically converts it to utf8 to automatically recognize the encoding and convert it to utf8 * ituibar.com * functioncharacet ($ data) {if (! Empty ($ data) {$ fileTypemb_detect_encoding ($ date

Php has an automatic identification function mb_detect_encoding (), the following code is the method for detecting Article encoding and automatically converting to utf8 // automatically recognizing the encoding and automatically converting to utf8/* Love push http://ituibar.com */function characet ($ data) {if (! Empty ($ data) {$ fileType = mb_detect_encoding ($ date

Php has an automatic identification function mb_detect_encoding (). The following code is used to detect the article encoding and convert it to utf8 automatically.

// Automatically recognize the encoding and convert it to utf8/* Love push http://ituibar.com */function characet ($ data) {if (! Empty ($ data) {$ fileType = mb_detect_encoding ($ date, array ('utf-8', 'gbk', 'latin1', 'big5 ')); if ($ fileType! = 'Utf-8') {$ data = mb_convert_encoding ($ data, 'utf-8', $ fileType) ;}} return $ date ;}

Original article address: the php function mb_detect_encoding automatically identifies the encoding and converts it to utf8. Thanks for sharing this with the original author.

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.