Summary of signature problems in the UTF-8 file encoding format

Source: Internet
Author: User
Tags html header

The file header contains BOM information (three bytes.
The advantage is that the multi-encoding editor can correctly recognize the file encoding.

Micro
Soft added ef bb bf three bytes before your own UTF-8 format text file,
Notepad on WindowsProgramIt is based on the three bytes to determine whether a text file is ascii or UTF-8, but this is only a Microsoft mark,
Other platforms do not make such a mark on UTF-8 text files.

Identify whether UTF-8 files contain BOM Method:
1, open the file with a UltraEdit-32, switch to the hexadecimal editing mode, check whether the file header ef bb bf;
2. use Dreamweaver to view the page attributes and check whether there is a check mark before "including Unicode signature Bom;
3, open with Windows notepad, select "Save as", see the default file encoding is UTF-8 or ANSI, if it is ANSI without Bom.

Remove the UTF-8 format BOM method in files:
Open with ulteredit, switch to the hexadecimal editing mode, and replace the first three bytes (that is, the damn ef bb bf) with 20 (space ASCII code value ), save (note that the automatic backup function is disabled during storage), switch to the default editing mode, and remove the first three spaces.

When the UTF-8 encoding content with signature is parsed by the browser, the browser can judge the use of UTF-8 encoding to parse according to the signature directly, when the signature is not carried, the browser will determine based on the content encoding. In short, the signature will be more easily parsed by the browser in the correct encoding method.

The latest development process involves a very boring question, with a .aspxpage or a .shtml page on one site. They all reference a public header file, for example: <! -- # Include file = "html/header.htm" --> the problem arises.

1> .aspx0000.shtml1_header.htmall pages are marked with 8 signatures. When the .aspxpage is normal, a blank area is displayed on the top of the .shtml page.

2> .aspx0000.shtml utf-8, header.htm00008, ..shtml page normal,. ASPX page garbled

3> the .aspx0000.shtml1_header.htm page uses UTF-8 without signature encoding, and the website encoding is set to UTF-8 in Web. config (this item is very important. If it is not configured, garbled characters will occur), and everything is normal at this time.

Speaking of this, maybe we think that according to the third way to solve the problem, in fact, otherwise, we know that the default vs encoding is UTF-8 with signature, the use of such encoding naturally has its advantages,ArticleThe difference between signature and non-signature has been described at the beginning. Obviously, signature encoding is the mainstream.

Most
Conclusion: The bottom line is that when .shtml with a signature reference to a signed HTML header file, there will be a blank section above. Finally, the problem is found, which is solved in IIS.
The DLL used to parse .shtml is c: \ windows \ system32 \ inetsrv \ ssinc. dll, And the DLL used to parse. aspx is C:
\ Windows \ Microsoft. NET \ framework \ v2.0.50727 \ aspnet_isapi.dll.
The difference in UTF-8 encoded files with signatures causes the above problems.

How can we solve the above problems? Two solutions: first, get two header reference files (encoding: UTF-8 and UTF-8 with signature), which are applied. aspx (UTF-8 with signature) and. shtml (UTF-8); 2: Use all pages. aspx suffix.

Transferred from:

Http://www.cnblogs.com/Impulse/archive/2013/04/15/3022113.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.