Diagnostic Queries
Symptoms
A character that is valid in one encoding has no representation in the target encoding during conversion. PostgreSQL raises SQLSTATE 22P05 (untranslatable_character).
- Happens when converting between database and client encodings.
- The message names both encodings and the byte sequence.
- Typical when a database is LATIN1 but the data contains characters only in UTF-8.
What the server log shows
ERROR: character with byte sequence 0xe2 0x82 0xac in encoding "UTF8" has no equivalent in encoding "LATIN1"
Why PostgreSQL raises this — what the manual says
Section 23.3.3 Automatic Character Set Conversion Between Server and Client:
“If the conversion of a particular character is not possible — suppose you chose EUC_JP for the server and LATIN1 for the client, and some Japanese characters are returned that do not have a representation in LATIN1 — an error is reported.”
When the client and database encodings differ, PostgreSQL converts each character through its conversion tables. A character with no mapping in the destination encoding (e.g. € into LATIN1) cannot be converted and fails with 22P05.
Common causes
- A LATIN1 database receiving characters that only exist in UTF-8.
- A client encoding too narrow for the stored data.
- Mixing encodings across an application stack.
How to fix it
- Use a UTF-8 database encoding so all characters are representable.
- Set
client_encodingto one that covers the data. - Sanitize/transliterate characters that the target encoding cannot store.
Related & next steps
Reference: PostgreSQL 18 Section 24.3 “Character Set Support”.
Thanks — noted. This helps keep the database accurate.