UTF-8 and UTF-8 without BOM)

Source: Internet
Author: User
Tags blank page

Differences between the two:

The Unicode specification has the concept of BOM. Bom -- byte order mark, which is a mark of the byte order. Here is a description of BOM:

There is a character named "Zero Width no-break space" in the UCS encoding, and its encoding is feff. Fffe does not exist in the UCs, so it should not appear in actual transmission. We recommend that you transmit the character "Zero Width no-break space" before transmitting the byte stream in the UCS specification ". In this way, if the receiver receives feff, it indicates that the byte stream is big-Endian; if it receives fffe, it indicates that the byte stream is little-Endian. Therefore, the character "Zero Width no-break space" is also called Bom.

The UTF-8 does not need BOM to indicate the byte order, but BOM can be used to indicate the encoding method. The UTF-8 code for the character "Zero Width no-break space" is ef bb bf. So if the receiver receives a byte stream starting with ef bb bf, it will know that this is UTF-8 encoding.

Windows uses BOM to mark the encoding of text files.

In addition, the Unicode website FAQ-BOM detailed Bom. The natural authority of the official website is only in English, and it looks hard.

Bom occupies three bytes of the UTF-8-encoded file. If you use NotePad to save a text file as a UTF-8 encoding method, open the file with ue, switch to the hexadecimal editing status, you can see the beginning of fffe. This is a good way to identify the UTF-8 encoding file, the software through BOM to identify whether the file is UTF-8 encoding, many software also requires that the file to be read must carry Bom. However, there are still a lot of software that cannot recognize Bom. When I was studying Firefox, I knew that in earlier versions of Firefox, BOM was not available for extensions, but later versions of Firefox 1.5 began to support Bom. Now, PHP does not support Bom.

PHP did not consider the BOM issue during design, that is, he would not ignore the three characters at the beginning of the BOM in a UTF-8-encoded file. Because it must be in
On the bo-blog wiki, we can see that the bo-blog using PHP is also troubled by BOM. Another problem was mentioned: "restricted by the cookie sending mechanism, BOM files already exist at the beginning of these files, the cookie cannot be sent (because PHP has already sent a file header before sending the cookie), so the login and logout functions are invalid. All functions dependent on cookies and sessions are invalid ." This should be the reason why a blank page appears in the WordPress background. Because any executed file contains Bom, all three characters will be sent, resulting in invalid functionality relying on cookies and sessions.

Solution: You can use Notepad ++ or other text editing software to dump to the UTF-8 without BOM format

 

Dump In a Windows text editor to a UTF-8 format that contains BOM

 

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.