XML technologies / XML / XML in a Nutshell / Internationalization / The default character set for XML documents

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

Before an XML parser can read a document, it must know the document’s character set and encoding. Sometimes external metadata tells the parser which encoding is used. For example, an HTTP header could include a Content-type header, as shown below:

Content-type: text/html; charset=ISO-8859-1

However, XML parsers generally cannot rely on such information being available. Even when it is, they cannot necessarily assume it is correct. An XML parser therefore tries to infer the character set from the document’s first characters. The main tests performed by the parser include the following:

Parsers that understand EBCDIC or UCS-4 could use similar heuristics to recognize those encodings. However, UCS-4 is not yet really used and is mainly of theoretical interest, while EBCDIC is an old family of character sets that should not be used in new documents. Neither of these character sets is important in practice.

  

 

 

 

back to top