BOM字符列表

List of BOM characters

是否有可能使用的 BOM 字符列表?目前为止遇到过:

\x00\x00\xfe\xff    UTF-32, big-endian
\xff\xfe\x00\x00    UTF-32, little-endian
\xfe\xff            UTF-16, big-endian
\xff\xfe            UTF-16, little-endian
\xef\xbb\xbf        UTF-8

还有什么我遗漏的吗?

简短回答:不,您已经涵盖了它们。

根据 Unicode 规范,UTF-8、UTF-16 和 UTF-32 是 3 种通用编码类型。他们实际上将 UTF-16、UTF-16LE 和 UTF-16BE 列为单独的编码,类似地 UTF-32、UTF-32LE 和 UTF-32BE。

重要的是要知道,如果字符流明确编码为 LE 或 BE 形式之一,则必须将前导 0xFFFE 解释为 U+FEFF 零宽度不间断 Space。即

UTF-16BE  initial FE FF is treated as U+FEFF
UTF-16LE  initial FF FE is treated as U+FEFF
UTF-32BE  initial 00 00 FE FF is treated as U+FEFF
UTF-32LE  initial FF FE 00 00 is treated as U+FEFF

有关详细信息,请参阅 http://www.unicode.org/versions/Unicode11.0.0/ch03.pdf#G2212