Search code examples
postgresqlwindowscharacter-encodingpsql

psql: weird error output encoding on Windows 10


Whenever I make a syntax error in psql, no matter what the problem is, psql shows only:

ERROR:  character with byte sequence 0xd0 0x9e in encoding "UTF8" has no equivalent in encoding "WIN1252"

without specifying the issue.

I am doing it on localhost.

I have tried changing the codepage to utf8 (via chcp 65001) and using SET CLIENT_ENCODING TO 'utf8' in psql itself. After that, errors are shown, but in strange encoding. I need it to show errors in English.

Error output I get after setting chcp 65001 and using SET CLIENT_ENCODING TO 'utf8':

Error output I get after setting chcp 65001 and using "SET CLIENT_ENCODING TO 'utf8'"

Error output I get without doing both of those:

Error output I get without doing both of those

EDIT: By running "\encoding UTF8" and "set lc_messages to 'en_us.utf-8';", it now shows errors in proper encoding. Thanks to Jorge Campos.


Solution

  • If you have configured PostgreSQL to send Russian error messages, don't set your client encoding to WIN1252, because Cyrillic letters cannot be converted to that encoding.

    You should set lc_messages = C in postgresql.conf and reload PostgreSQL to get English error messages.