PostgreSQL Error 22021: character not in repertoire

PostgreSQL error code 22021 (character_not_in_repertoire) occurs when you attempt to insert, convert, or process a character that does not exist within the allowed character repertoire of the current database or target encoding. This typically happens when multibyte characters (such as Korean, Japanese, emoji, or special Unicode symbols) are used in a database configured with a restrictive encoding like SQL_ASCII or LATIN1.

Top 3 Causes

1. Database and Client Encoding Mismatch

When your database encoding is SQL_ASCII or LATIN1 but your client sends UTF-8 encoded multibyte characters, PostgreSQL cannot map those bytes to the database's character repertoire.