XML Files

The encoding for XML-format files is declared explicitly within the XML file itself, where the first line, the XML declaration, may look like this:

<?xml version="1.0" encoding="ISO-8859-1"?>

This tells the XML parser that the file uses the ISO-8859-1 encoding, a typical encoding for Western European languages. If the XML declaration is omitted, the parser will assume UTF-8 encoding, which covers most modern languages and many others, besides being based on the Unicode standard. It is very important that the XML declaration matches the actual file encoding. The declaration does not determine the encoding, it only identifies it; changing the declaration does not automatically change the file encoding. If you use a specialized XML editor application, then it will probably recognize the declaration and change the file encoding for you. Most plain-text editors will not do this, so you must ensure that you select the correct encoding in your editor before saving the file.

It is highly recommended that UTF-8 encoding is used for XML files.