XML文件中正确的UTF8编码声明是什么?我见过两个。
<?xml version="1.0" encoding="UTF-8"?>
...
或
<?xml version="1.0" encoding="UTF8"?>
...
答案 0 :(得分:5)
XML规范(https://www.w3.org/TR/REC-xml/#charencoding)说:
在编码声明中,值&#34; UTF-8&#34;,&#34; UTF-16&#34;,&#34; ISO-10646-UCS-2&#34;和&#34; ISO-10646-UCS-4&#34;应该用于Unicode / ISO / IEC 10646 ......
的各种编码和转换
此外,&#34;编码&#34;的值可以是IANA-CHARSETS(http://www.iana.org/assignments/character-sets/character-sets.xhtml)的任何值。
UTF-8被定义为&#34; UTF-8&#34;或其别名&#34; csUTF8&#34;
因此,它应该是&#34; UTF-8&#34;