Specifying the encoding

You can choose how to specify the encoding for parsing an XML document that is in an alphanumeric data item.

About this task

The preferred way is to omit the encoding declaration from the document and to rely instead on the external code-page specification.

Omitting the encoding declaration makes it possible to more easily transmit an XML document between heterogeneous systems. (If you included an encoding declaration, you would need to update it to reflect any code-page translation imposed by the transmission process.)

The code page used for parsing an alphanumeric XML document that does not have an encoding declaration is the runtime code page.

You can instead specify an encoding declaration in the XML declaration with which most XML documents begin. For example:

<?xml version="1.0" encoding="ibm-1140"?>

Note that the XML parser generates an exception if it encounters an XML declaration that does not begin in the first byte of an XML document.

If you specify an encoding declaration, use one of the primary or alias code-page names that are supported by the ICU conversion libraries. The code-page names are documented in the related reference about the ICU converter explorer.

For more information about the CCSIDs that are supported for XML parsing, see the related reference about the encoding of XML documents.

related concepts  
XML input document encoding