Levijatanu
Levijatanu

Reputation: 418

DB2 Code conversion from Unicode to ISO8859-2 and back

When saving some string from XML (UTF8 encoded) containing Latvian capital (Rīga). Riga comes this I with macron (Unicode) to DB2.

Database code page is not Unicode but unfortunately ISO8859-2. Conversion occurs and this special I gets substituted with X'1A ((explained here IBM docs))

Again when I use same columns to reproduce original XML my validation fails with:

An invalid XML character (Unicode: 0x1a) was found in the element content of the document.

Why did they choose invalid XML character as substitution and what's preferred way to do this kind of thing?

We are using Java for XML input and output and do not need to preserve I with macron, some kind of replacment charater would be fine, one that doesn't mess with XML. Filtering all characters that's not representable in the database code page doesn't seam as good idea?

Upvotes: 1

Views: 1351

Answers (1)

Stavr00
Stavr00

Reputation: 3314

Have you tried to cast the column back to unicode?

CAST(column AS VARCHAR(255) CCSID UNICODE )

Upvotes: 0

Related Questions