Solutions to style disorder caused by UTF-8BOM

Source: Internet
Author: User
Solutions to style disorder caused by UTF-8BOM
UTF-8 is a unicode character encoding method that is frequently used in web applications. the advantage of UTF-8 is that it is a variable-length encoding method, the length of the ANSII code is 1 byte. in this way, network bandwidth can be greatly reduced when a large number of ASCII character sets of webpages are transmitted.

UTF-8 is a unicode character encoding method that is frequently used in web applications. the advantage of UTF-8 is that it is a variable-length encoding method, the length of the ANSII code is 1 byte. in this way, network bandwidth can be greatly reduced when a large number of ASCII character sets of webpages are transmitted.

When using UTF-8 encoding to compile a webpage, the bom (Byte Order Mark) issue often causes some unknown blank lines or garbled characters in the webpage. These are because the UTF-8 encoding method is not mandatory for bom. Therefore, different UTF-8 encoding methods may occur when saving files. For example, some browsers (FireFox) can automatically filter out all UTF-8 bom, and some (IE) can only filter out bom once (why? This problem occurs when you Include multiple files ).

Use editplus or another editor to delete the BOM signature in the file and refresh the page. The style is normal.

BOM description:

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..

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 does not consider BOM issues during design and does not ignore the three characters at the beginning of the BOM in a UTF-8-encoded file. Because it must be in

English plug-ins and templates in foreign countries are generally encoded using ASCII codes without BOM. only domestic plug-ins and templates may cause problems without the author's knowledge.

In addition, modify the template, because the output page uses UTF-8 encoding, then modify the template if there are added Chinese characters, you must convert the file into UTF-8 encoding to display normally, in this case, if the BOM is automatically added to the editor, the three characters will be output on the page. the display effect depends on the browser, which is generally a blank line or garbled code. Articles you may be interested in: php instances: check and clear BOM information at the beginning of the file implementation code Php remove bom header information in batches php remove bom header code share simple example of BOM data on the PHP filter page check whether the Php file has a bom header check the bom method in php file and clear the difference between bom and DOM function in php file; check and delete BOM in UTF-8 coding

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.