UTF-8 和没有 BOM 的 UTF-8 有什么区别? [英] What's the difference between UTF-8 and UTF-8 without BOM?

查看:32
本文介绍了UTF-8 和没有 BOM 的 UTF-8 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UTF-8 和没有 BOM 的 UTF-8 有什么区别?哪个更好?

What's different between UTF-8 and UTF-8 without a BOM? Which is better?

推荐答案

UTF-8 BOM 是文本流开头的 字节 序列(0xEF, 0xBB, 0xBF) 允许读者更可靠地猜测文件是否以 UTF-8 编码.

The UTF-8 BOM is a sequence of bytes at the start of a text stream (0xEF, 0xBB, 0xBF) that allows the reader to more reliably guess a file as being encoded in UTF-8.

通常,BOM 用于表示 字节序,但由于字节序与 UTF-8 无关,因此不需要 BOM.

Normally, the BOM is used to signal the endianness of an encoding, but since endianness is irrelevant to UTF-8, the BOM is unnecessary.

根据 Unicode 标准BOM 用于不推荐使用 UTF-8 文件:

... UTF-8 既不要求也不建议使用 BOM,但可能在 UTF-8 数据从使用 BOM 的其他编码形式转换或 BOM 用作 UTF 的情况下遇到-8 签名.请参阅第 16.8 节,特价,了解更多信息.

2.6 Encoding Schemes

... Use of a BOM is neither required nor recommended for UTF-8, but may be encountered in contexts where UTF-8 data is converted from other encoding forms that use a BOM or where the BOM is used as a UTF-8 signature. See the "Byte Order Mark" subsection in Section 16.8, Specials, for more information.

这篇关于UTF-8 和没有 BOM 的 UTF-8 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆