Encoding scenarios for retrieval of XML data with implicit serialization
Examples demonstrate how the target encoding and application code page affect data conversion, truncation, and internal encoding during XML data retrieval with implicit serialization.
Only scenario 1 and scenario 2 apply to Java™ and .NET applications, because the application code page for Java applications is always Unicode. In general, code page conversion is not a problem for Java and .NET applications.
Scenario 1
| Encoding source | Value |
|---|---|
| Target data encoding | UTF-8 Unicode |
| Target application data type | Binary |
| Application code page | Not applicable |
SELECT XMLCOL FROM T1
Character conversion: None.
Data loss: None.
Truncation: None.
<?xml version="1.0" encoding="UTF-8" ?>For Java applications, no encoding declaration
is added, unless you cast the data as the com.ibm.db2.jcc.DB2Xml type,
and use a getDB2Xmlxxx method
to retrieve the data. The declaration that is added depends on the getDB2Xmlxxx that
you use.
For .NET applications, no encoding declaration is added or removed.
Scenario 2
| Encoding source | Value |
|---|---|
| Target data encoding | UTF-16 Unicode |
| Target application data type | Graphic |
| Application code page | Any SBCS code page or CCSID 1208 |
SELECT XMLCOL FROM T1
Character conversion: Data is converted from UTF-8 to UTF-16.
Data loss: None.
Truncation: Truncation can occur during conversion from UTF-8 to UTF-16, due to expansion.
<?xml version="1.0" encoding="UTF-16" ?>For Java applications, no encoding declaration
is added, unless you cast the data as the com.ibm.db2.jcc.DB2Xml type,
and use a getDB2Xmlxxx method
to retrieve the data. The declaration that is added depends on the getDB2Xmlxxx that
you use.
For .NET applications, no encoding declaration is added or removed.
Scenario 3
| Encoding source | Value |
|---|---|
| Target data encoding | ISO-8859-1 data |
| Target application data type | Character |
| Application code page | 819 |
SELECT XMLCOL FROM T1
Character conversion: Data is converted from UTF-8 to CCSID 819.
Data loss: Possible data loss. Some UTF-8 characters cannot be represented in CCSID 819. The Db2® database system generates an error.
Truncation: None.
<?xml version="1.0" encoding="ISO-8859-1" ?>Scenario 4
| Encoding source | Value |
|---|---|
| Target data encoding | Windows-31J data (superset of Shift_JIS) |
| Target application data type | Graphic |
| Application code page | 943 |
SELECT XMLCOL FROM T1
Character conversion: Data is converted from UTF-8 to CCSID 943.
Data loss: Possible data loss. Some UTF-8 characters cannot be represented in CCSID 943. The Db2 database system generates an error.
Truncation: Truncation can occur during conversion from UTF-8 to CCSID 943 due to expansion.
<?xml version="1.0" encoding="Windows-31J" ?>