The database I'm working with has sometimes UTF-8 encoded surrogate pairs, for example:
SELECT id, SUBSTR(description, 72, 4) as str, RAWTOHEX(SUBSTR(description, 72, 4)) as hex
FROM table WHERE id = 13;
returns
ID | str | hex |
---|---|---|
13 | -S | EDA0B5EDBBBD2D53 |
When I try to retrieve this entry, I'm getting UnicodeDecodeError
as this is not valid UTF-8 sequence. How can I convince cx_Oracle
(I have to use 5.2.1 version for now) to unmangle this sequence (I know that Django fixes this error somehow, but don't see how it's done).