XML SET ENCODING

This statement has the following parameter:

Description

Parameter

Description

Encoding

A nonnumeric literal or an identifier of an alphanumeric data item, the value of which must be either 'local' or 'utf-8'. If the value is "local", then the character encoding used by the operating system is used. If the value is 'utf-8', then the data is treated as UTF-8 encoded. The parameter value is case insensitive. Any hyphen and underscore characters are optional. For example, 'LOCAL', 'Local', and 'local' are equivalent. 'UTF-8', 'Utf_8', and 'utf8' are also equivalent.

The XML SET ENCODING statement allows the developer to specify the character encoding of data within a COBOL data structure. The developer may use this statement to switch between the local character encoding and UTF-8. On Windows, the local character encoding matches the native character set of the run-time system; that is, it is specified by the Windows ANSI code page or Windows OEM code page depending on the native character set of the run-time system. On UNIX, the local character encoding is specified by the value of the MF_XMLEXT_LOCAL_ENCODING environment variable, with a default of MF_LATIN_9 if the variable is not defined.

Note: If the value of the Encoding parameter specifies 'utf-8', the MF_XMLEXT_LOCAL_ENCODING environment variable is ignored. For more information on this environment variable, see COBOL and Character Encoding.

Although the XML SET ENCODING statement does not affect the character encoding of the XML document, it does affect the character encoding of the data in the COBOL program. For more information, see Data Representation for more information.

The XML SET ENCODING statement returns an error status value if the value of the Encoding parameter is not recognized.

Example

XML SET ENCODING "local".
IF NOT XML-OK GO TO EXIT-1.

The default value is 'local'. If XML SET ENCODING is never called, the default is used.