I have a PostgreSQL database which uses an arcane text encoding, and I can't change that. Is there a way tostore text in UTF-7 transparently (for the informed client) so that the database engine doesn't complain that it cannot convert Unicode characters, but the client can still use any Unicode characters out there? I can do this conversion manually, but I hope there is a way to do it without manual conversion.
Asked
Active
Viewed 482 times
1 Answers
3
You can use SQL_ASCII
, which tells the database to pass the bytes for text transparently without any validation or conversion.
This is usually a terrible idea that leads to a horrid mix of incompatible and mismatched text encodings in a DB, with some apps inserting UTF-8, others latin-1, etc. It is an option if you need to work with an encoding that the database cannot actually understand, though.
Your alternative would be to add support for utf-7 to PostgreSQL. This might not be too difficult as all the encoding handling is pretty well abstracted.

Craig Ringer
- 11,083
- 9
- 40
- 61
-
I can't change the database encoding, and I don't control the database server. Is it possible to use SQL_ASCII as the client encoding if the server encoding is something else? – Alexei Averchenko Nov 24 '13 at 23:21
-
@AlexeiAverchenko If the server encoding is fixed, your only option would be to store data as `bytea` or something like base64 `text` and do your encoding/decoding client side. That'll be painful. – Craig Ringer Nov 25 '13 at 01:22