Question & Answer
Question
Cause
The difference between two is invalid byte (FE) vs incomplete character (EE)
Answer
x'FE' and x'EE' both represent one byte but,
FE is invalid byte value as per Unicode rule. DB2 considers it as single byte character.
Therefore it is ok to replace x'FE' with 'A'
Our logic, here we are replacing invalid bytes to a valid value. Valid use case for translate function.
EE is valid byte value as per Unicode rule but should be part of a 3 bytes (multi-byte) character sequence.
Since the third argument is incorrect, that's why there is error (SQL0176N).
Replacing x'EE' with 'A' is wrong.
First byte EE, a valid character represent has 3 byte, If we replace EE with A , then rest of character data after EE would become invalid. It can lead to invalid Unicode characters. So, Db2 is raising error.
The difference between two are invalid byte (FE) vs incomplete character (EE)
Unicode rule regarding valid and invalid byte values (well-formed byte sequence) can be found in Table 3-7 in Unicode docs http://www.unicode.org/versions/Unicode6.2.0/ch03.pdf
In addition document also mentions the following,
As a consequence of the well-formedness conditions specified in Table 3-7, the following byte values are disallowed in UTF-8: C0–C1, F5–FF.
Related Information
Was this topic helpful?
Document Information
More support for:
DB2 Universal Database Enterprise Edition
Software version:
All Versions
Document number:
6953659
Modified date:
23 March 2023
UID
ibm16953659