Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 vs UTF8 in XML files

Tags:

xml

utf-8

utf

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"?>
...
like image 645
sdc Avatar asked Feb 28 '26 13:02

sdc


1 Answers

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"

like image 130
Alastair McCormack Avatar answered Mar 03 '26 06:03

Alastair McCormack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!