当我使用文本编辑器“Notepad++”时, 我发现一个“以UTF-8无BOM格式编码”的方式,如果Web页面的源文件以 UTF-8 格式编码的话,在校验 xhtml文件时会出来一条如下警告:
Byte-Order Mark found in UTF-8 File.
The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to cause problems for some text editors and older browsers. You may want to consider avoiding its use until it is better supported.
意思是说使用utf-8的格式编码会在一些编辑器和老的浏览器上产生问题,最好是考虑避免这些问题,除非它们得到更好的支持。在这里我得到了更多的信息 http://unicode.org :
UTF-8 is most common on the web. UTF-16 is used by Java and Windows. UTF-32 is used by various Unix systems. The conversions between all of them are algorithmically based, fast and lossless. This makes it easy to support data input or output in multiple formats, while using a particular UTF for internal storage or processing.
What is a BOM?
A byte order mark (BOM) consists of the character code U+FEFF at the beginning of a data stream, where it can be used as a signature defining the byte order and encoding form, primarily of unmarked plaintext files. Under some higher level protocols, use of a BOM may be mandatory (or prohibited) in the Unicode data stream defined in that protocol.
Where is a BOM useful?
A BOM is useful at the beginning of files that are typed as text, but for which it is not known whether they are in big or little endian format—it can also serve as a hint indicating that the file is in Unicode, as opposed to in a legacy encoding and furthermore, it act as a signature for the specific encoding form used .
A BOM can be used as a signature no matter how the Unicode text is transformed: UTF-16, UTF-8, UTF-7, etc. The exact bytes comprising the BOM will be whatever the Unicode character FEFF is converted into by that transformation format. In that form, the BOM serves to indicate both that it is a Unicode file, and which of the formats it is in.
解除这个警告的方法仅仅是将Web源文件以UTF-8无BOM格式编码即可。