Xml Encoding
# XML Encoding
* * *
XML documents can contain non-ASCII characters, such as Norwegian æ ø å, or French ê è é.
To avoid errors, you need to specify an XML encoding, or save your XML file as Unicode.
* * *
## XML Encoding Errors
If you load an XML document, you may encounter two different errors indicating encoding issues:
**Invalid character found in text content.**
If your XML contains non-ASCII characters and the file is saved as a single-byte ANSI (or ASCII) without specifying an encoding, you will receive an error.
(
(
**Switching Current Encoding to an Unsupported Specified Encoding**
If your XML file is saved as a double-byte Unicode (or UTF-16) with a specified single-byte encoding (WINDOWS-1252, ISO-8859-1, UTF-8), you will get an error.
Similarly, if your XML file is saved as a single-byte ANSI (or ASCII) with a specified double-byte encoding (UTF-16), you will also encounter an error.
(
(
* * *
## Windows Notepad
Windows Notepad saves files by default as single-byte ANSI (ASCII).
If you choose "Save As...", you can specify ANSI, UTF-8, Unicode (UTF-16), or Unicode Big.
Save the following XML as ANSI, UTF-8, and Unicode (note that the document does not include any encoding attributes).
Jani
Tove
Norwegian: æøå. French: êèé
Try dragging the file into your browser and see the results. Different browsers will display different outcomes.
Experiences with Different Encodings:
Please try:
(
(
* * *
## Conclusion
* Always use encoding attributes
* Use editors that support encoding
*
YouTip