Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
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 1:22
Yeah, I thought as much :( Thanks anyway! – Alexei Averchenko Nov 25 '13 at 5:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.