XML文件中的UTF-8和UTF8

时间:2022-09-10 22:21:54

What is the correct UTF8 encoding declaration in XML files? I have seen both.

XML文件中正确的UTF8编码声明是什么?我看过。

<?xml version="1.0" encoding="UTF-8"?>
...

or

<?xml version="1.0" encoding="UTF8"?>
...

1 个解决方案

#1


4  

The XML specification (https://www.w3.org/TR/REC-xml/#charencoding), says:

XML规范(https://www.w3.org/TR/REC-xml/#charencoding)说:

In an encoding declaration, the values " UTF-8 ", " UTF-16 ", " ISO-10646-UCS-2 ", and " ISO-10646-UCS-4 " should be used for the various encodings and transformations of Unicode / ISO/IEC 10646...

在一个编码声明中,值“UTF-8”、“UTF-16”、“ISO-10646- ucs -2”和“ISO-10646- ucs -4”应该用于Unicode / ISO/IEC 10646的各种编码和转换…

Further, the value of "encoding" can be any value from IANA-CHARSETS (http://www.iana.org/assignments/character-sets/character-sets.xhtml).

此外,“编码”的值可以是来自IANA-CHARSETS的任何值(http://www.iana.org/assignments/characters - sets/characters -sets.xhtml)。

UTF-8 is defined as "UTF-8" or its alias "csUTF8"

UTF-8被定义为“UTF-8”或别名“csUTF8”

Therefore, it should be "UTF-8"

因此,它应该是“UTF-8”

#1


4  

The XML specification (https://www.w3.org/TR/REC-xml/#charencoding), says:

XML规范(https://www.w3.org/TR/REC-xml/#charencoding)说:

In an encoding declaration, the values " UTF-8 ", " UTF-16 ", " ISO-10646-UCS-2 ", and " ISO-10646-UCS-4 " should be used for the various encodings and transformations of Unicode / ISO/IEC 10646...

在一个编码声明中,值“UTF-8”、“UTF-16”、“ISO-10646- ucs -2”和“ISO-10646- ucs -4”应该用于Unicode / ISO/IEC 10646的各种编码和转换…

Further, the value of "encoding" can be any value from IANA-CHARSETS (http://www.iana.org/assignments/character-sets/character-sets.xhtml).

此外,“编码”的值可以是来自IANA-CHARSETS的任何值(http://www.iana.org/assignments/characters - sets/characters -sets.xhtml)。

UTF-8 is defined as "UTF-8" or its alias "csUTF8"

UTF-8被定义为“UTF-8”或别名“csUTF8”

Therefore, it should be "UTF-8"

因此,它应该是“UTF-8”