简体   繁体   English

BOM是否用于2字节Unicode文本文件?

[英]Is BOM used for 2-byte Unicode text files?

我知道BOM表用于UTF-8文件,但是对于每个字符为2个字节的文本文件呢,我也应该在其上添加字节顺序标记吗?

BOM's were invented for UCS-2 and UTF-16, and then only later appropriated by Microsoft (and then XML) for UTF-8. BOM是为UCS-2和UTF-16发明的,后来才被Microsoft(然后是XML)用于UTF-8。 Think about the name: 'byte order mark'. 考虑一下名称:“字节顺序标记”。 UTF-8 has only one possible byte order, so it doesn't need a BOM to reveal the order. UTF-8仅具有一个可能的字节顺序,因此不需要BOM即可显示该顺序。 The three-byte sequence for U+FEFF in UTF-8 has, instead, become a Unicode signature for file type sniffing. UTF-8中U + FEFF的三字节序列已成为文件类型嗅探的Unicode签名。

However, early versions of the XML support in Java did not respond well to a UTF-8 BOM, in spite of the inclusion of the UTF-8 BOM in the XML standard. 但是,尽管XML标准中包含了UTF-8 BOM,但是Java中对XML的早期支持对UTF-8 BOM的响应并不理想。 Further, a file with a BOM can't be simply concatenated onto another file, because U+FEFF isn't BOM in the middle of the file; 此外,带有BOM的文件不能简单地串联到另一个文件,因为U + FEFF不在文件中间。 it's ZWNBSP. 是ZWNBSP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM