Php: how to set the encoding format _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php sets the encoding format. A. if you want to use gb2312 encoding, php needs to output the header ("Content-Type: texthtml; charsetgb2312), add metahttp-equivContent-Typecontenttexthtml to the static page, and. if you want to use gb2312 encoding, php needs to output the header ("Content-Type: text/html; charset = gb2312") and add it to the static page. The encoding format of all files is ANSI, which can be opened in Notepad. save it as ANSI and overwrite the source file.

B. If you want to use UTF-8 encoding, php needs to output headers: header ("Content-Type: text/html; charset = utf-8") and add static pages The encoding format of all files is UTF-8.

Recently, I need to use the iconv function to convert the captured UTF-8 encoded page to gb2312. I found that only the iconv function can be used to convert the captured data into less data for no reason. I was depressed for a while. I checked the information on the Internet to find out that this is a bug in the iconv function. Iconv fails to convert the character "-" to gb2312. The solution is simple, that is, after adding "// IGNORE" after the code to be converted, that is, the second parameter of the iconv function, as follows:

Iconv ("UTF-8", "GB2312 // IGNORE", $ data)

Ignore indicates that the conversion error is ignored. without the ignore parameter, all strings after this character cannot be saved.

Http://www.bkjia.com/PHPjc/326544.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/326544.htmlTechArticlea. if you want to use gb2312 encoding, php needs to output the header: header ("Content-Type: text/html; charset = gb2312 "), add meta http-equiv = "Content-Type" content = "text/html ;...

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.