Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that there is a blank line in front of the utf8 encoding web page include file

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to solve the problem that there is a blank line in front of the utf8 coding web page containing files. I hope you will gain something after reading this article. Let's discuss it together.

The page is encoded by UTF8, and the header and tail use the method of template including files. As a result, there is an extra blank line of about 10px in the header and tail, and there is nothing at all.

The reason is that when all utf8 codes are used to include files, the final binary stream contains multiple UTF8 BOM tags, and IE cannot normally parse pages containing multiple UTF8 BOM tags and directly replace them with actual displayed carriage returns, which leads to a blank line, but firefox does not have this problem.

Therefore, if the template uses the included method to include multiple utf8 files that need to be saved with ultraedit, save as a function selection utf8 without bom format.

In addition, if the Chinese page places the title tag in the html head tag

BOM header:\ xEF\ xBB\ xBF,PHP4, 5 ignores BOM, so output directly before parsing. There is a special description of this problem in the w3.org standard FAQ:

Http://www.w3.org/International/questions/qa-utf8-bom

The details are as follows:

There is a character called "ZERO WIDTH NO-BREAK SPACE" in the UCS code, which is encoded as FEFF. FFFE is a character that does not exist in UCS, so it should not appear in the actual transmission. The UCS specification recommends that we transfer the character "ZERO WIDTH NO-BREAK SPACE" before transferring the byte stream. Thus, 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. So the character "ZERO WIDTH NO-BREAK SPACE" is also called BOM.

UTF-8 does not need BOM to indicate byte order, but BOM can be used to indicate how it is encoded. The UTF-8 encoding of the character "ZERO WIDTH NO-BREAK SPACE" is EF BB BF. So if the receiver receives a byte stream that starts with EF BB BF, it knows that this is UTF-8 coding.

Windows is the operating system that uses BOM to mark the encoding of text files: WindowsXP Professional, default character set: Chinese

1) notepad: you can automatically recognize the utf-8 encoding format file without bom, but you cannot control whether to add bom when saving the file. If you save the file, bom will be added.

2) editplus: can not automatically recognize the utf-8 encoding format file without bom, when saving the file, select UTF-8 format, will not write BOM header in the header.

3) UltraEdit: the most powerful function for character encoding, you can automatically identify utf-8 files with and without bom (which can be configured); when saving, you can choose whether or not to add bom through configuration.

(it is particularly important to note that when saving a newly created file, you need to choose Save as utf-8 no bom format)

Later, it was found that Notepad also supports utf-8 bom better, so it is recommended that you use it.

After reading this article, I believe you have a certain understanding of "how to solve the problem of blank lines in front of utf8 coding web pages containing documents". If you want to know more about it, welcome to follow the industry information channel, thank you for your reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report