How is non-default character encoding specified for an XML document?

Joe Sam Shirah

For non-default encoding, the XML text declaration should contain an encoding declaration as in the following examples:

<?xml encoding='UTF-8'?>

<?xml encoding='EUC-JP'?>

Acceptable character encoding names are from the familiar IANA Character Sets. For more information, see 4.3.3 Character Encoding in Entities in the Extensible Markup Language (XML) 1.0 sepcification.

See also What is the default encoding for HTML and XML?