Is “EF BF BF” an allowed character in XML (UTF-8)?

倖福魔咒の 提交于 2019-12-25 04:58:15

问题


Is "EF BF BF" an allowed character in XML (UTF-8)?

<?xml version="1.0" encoding="UTF-8" ?>
<XML>
    <DOCUMENT>
        <CONTENT>" "</CONTENT>
    </DOCUMENT>
</XML>

回答1:


If "EF BF BF" is a typo, and you meant "EF BB BF":

Yes, if it is the first bytes. They are the "BOM", Byte Order Mark, used to identify the endianness of the file.

For UTF-16 and UTF-32-encoded files this is mandatory.

For UTF-8, this is optional. Some systems might be confused by it if it is present, and it might give unexpected behavior if an UTF-8-file with BOM is used in a context expecting for example ISO-8859-1.

Edit: If "EF BF BF" isn't a typo, it is not valid UTF-8 anywhere in the file.



来源:https://stackoverflow.com/questions/10310210/is-ef-bf-bf-an-allowed-character-in-xml-utf-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!