This table shows what the encoding and encoding declaration will be based on the return data type of the XML value.
|Return Type of XML Value||Encoding||Encoding Declaration|
|XML type (in record/indicator mode)||UTF-8||
|CLOB or VARCHAR (in field mode, or when XMLSERIALIZE is called with CLOB or VARCHAR target type)||The encoding of the document received will match the session character set in use.||
|BLOB or VARBYTE (when XMLSERIALIZE is called with BLOB or VARBYTE target type)||The encoding of the XML value will be as specified by the user via the ENCODING clause in the XMLSERIALIZE function call. It is UTF-8 if an encoding is not specified.||The encoding declaration is as specified by user via the ENCODING clause or none.|
If the XML values are returned as XML, CLOB, or VARCHAR values, there is potential for mismatch between the actual encoding of the XML value and its encoding declaration. You can instruct the parser via parser-provided APIs to override the encoding declaration in the XML document based on external knowledge, such as knowing the session character set in use.