3

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

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

or

<?xml version="1.0" encoding="UTF8"?>
...
sdc
  • 2,603
  • 1
  • 27
  • 40
  • 1
    http://stackoverflow.com/questions/809620/utf8-or-utf-8 – har07 Mar 18 '16 at 22:08
  • 2
    Yes, I posted this question because that question is marked as opinion based due to the lack of a clear context. – sdc Mar 18 '16 at 22:09

1 Answers1

6

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

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...

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

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

Therefore, it should be "UTF-8"

Alastair McCormack
  • 26,573
  • 8
  • 77
  • 100