How default is the default encoding (UTF-8) in the XML Declaration?

后端 未结 4 431
执念已碎
执念已碎 2020-12-07 01:33

I know that the default encoding of XML is UTF-8. All XML consumers MUST and so on and so forth. So this is not just a question whether or not XML has a default encoding.

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 02:09

    The way I read the spec, UTF-8 is not the default encoding in an XML declaration. It is only the default encoding "for an entity which begins with neither a Byte Order Mark nor an encoding declaration". If a document is in UTF-16 and has a BOM, it may have an XML declaration without an encoding declaration or no XML declaration at all and still be valid XML.

    Only for documents without a BOM, the two XML declarations you mentioned should be equivalent.

提交回复
热议问题