Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-30 · container image postgres:17
22P05 appears when PostgreSQL converts text from the database encoding (UTF8 here) to another encoding and meets a character that the target encoding does not have. The message shows the character as bytes, for example 0xea 0xb9 0x80 (the Korean character 김) or 0xf0 0x9f 0x98 0x80 (the emoji 😀).
Use the byte sequence to find the row, then either export in an encoding that can hold the text (UTF8) or clean the characters before converting.
01COPY ... WITH (ENCODING 'LATIN1') on data that contains Korean
The export COPY customers TO STDOUT WITH (FORMAT csv, ENCODING 'LATIN1') wrote row 1 (Nord Trading) and then failed on row 2: 0xea 0xb9 0x80 in UTF8 has no equivalent in LATIN1. The rows already sent are a partial file.
Searching with name ~ '[^\x01-\xFF]' found row 2, 김철수. Exporting with ENCODING 'UTF8' wrote both rows.
Setup
CREATE TABLE customers (cust_id int PRIMARY KEY, name text);
INSERT INTO customers VALUES (1, 'Nord Trading'), (2, '김철수');CREATE TABLE
INSERT 0 2COPY customers TO STDOUT WITH (FORMAT csv, ENCODING 'LATIN1');1,Nord Trading
ERROR: 22P05: character with byte sequence 0xea 0xb9 0x80 in encoding "UTF8" has no equivalent in encoding "LATIN1"SELECT cust_id, name FROM customers WHERE name ~ '[^\x01-\xFF]'; cust_id | name
---------+--------
2 | 김철수
(1 row)If the receiving system really needs LATIN1, the Korean text cannot be kept as is; it must be changed or removed first.
COPY customers TO STDOUT WITH (FORMAT csv, ENCODING 'UTF8');1,Nord Trading
2,김철수02convert_to(..., 'EUC_KR') on text that contains an emoji
convert_to(body, 'EUC_KR') failed on 0xf0 0x9f 0x98 0x80 because EUC_KR has no emoji. The check found review 2, great 😀.
Removing characters outside the basic plane first with regexp_replace(body, '[\U00010000-\U0010FFFF]', '', 'g') let both rows convert.
Setup
CREATE TABLE reviews (review_id int PRIMARY KEY, body text);
INSERT INTO reviews VALUES (1, 'good'), (2, 'great 😀');CREATE TABLE
INSERT 0 2SELECT review_id, convert_to(body, 'EUC_KR') AS body_euckr FROM reviews ORDER BY review_id;ERROR: 22P05: character with byte sequence 0xf0 0x9f 0x98 0x80 in encoding "UTF8" has no equivalent in encoding "EUC_KR"SELECT review_id, body FROM reviews WHERE body ~ '[\U00010000-\U0010FFFF]'; review_id | body
-----------+----------
2 | great 😀
(1 row)SELECT review_id, convert_to(regexp_replace(body, '[\U00010000-\U0010FFFF]', '', 'g'), 'EUC_KR') AS body_euckr FROM reviews ORDER BY review_id; review_id | body_euckr
-----------+----------------
1 | \x676f6f64
2 | \x677265617420
(2 rows)FAQ
What does PostgreSQL 22P05 character has no equivalent in encoding mean?
A character in the text cannot be written in the target encoding, for example Korean in LATIN1 or an emoji in EUC_KR. The bytes in the message are that character in UTF8.
How do I find the row with the bad character?
Search with a regular expression for characters the target encoding lacks, e.g. ~ '[^\x01-\xFF]' for LATIN1 or ~ '[\U00010000-\U0010FFFF]' for emoji.
What is the difference between 22P05 and 22021?
22P05 means the character is valid but missing in the target encoding. 22021 means the bytes are not valid in the encoding at all.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12