1

How can I have a working PSQL console using UTF8 encoding under Windows?

I have a Windows server and client. The Postgres 12 database contains tables with content in multiple languages (ex: English, French (with characters such as é), Korean (with characters such as )).

The DB is encoded as UTF8.

The client_encoding is set to UTF8.

The console code page is set to 65001 (Microsoft's UTF8 codepage), and has a suitable font ( Lucida Console)

I must be able to properly display English and French text, query the DB in English and French and be able to "output something", i.e. not get any error, if touching text in another language.

The issue is I can't type / copy-paste any accented character. If I do, the special character acts as a comment but the input continues on the next line, and I need to close it again.

In the following example, note that é_fg is gone, that there is no prompt on the hij line and that the output concatenates abcd_hij on one line

myuser=> select 'abcd_é_fg';
hij
myuser'> klm';
 ?column?
----------
 abcd_hij+
 klm
(1 row)

The issue is really with the typing, because I can export and load files containing such chars.

Ex: save select 'é'; in sel.sql, run psql -U myuser -d mydb -f C:/sel.sql

will output

 ?column?
----------
 é

On the working well side, I can display what I need

select chr(8217); --sort of apostrophe
 chr
-----
 ’

select chr(48652);
 chr
-----
 브 --(though displayed as a square - unknown character, ok)

I have tried to set Windows language for non-Unicode program to UTF8, which had no effect on the issue.

If I set the code page to 1252 and the client-encoding to Win1252, I can display the accented chars, I can type them, but if I want to display text in another language like Korean I get and error

select chr(48652);

ERROR: character with byte sequence 0xeb 0xb8 0x8c in encoding "UTF8" has no equivalent in encoding "WIN1252"

11
  • Did you try using the "Lucida Console" font and running chcp 65001? Jun 16, 2020 at 13:18
  • @LaurenzAlbe Yes, both are set
    – JGH
    Jun 16, 2020 at 13:25
  • Then probably not. Blame Microsoft. You'll have to use a different client software (or use psql on a different operating system). Jun 16, 2020 at 13:35
  • I’d also ask the Postgres developers if this is a known issue and not actually a bug. Blaming Microsoft is what we often do, but they might not actually be at fault here. Jun 16, 2020 at 13:37
  • Other clients, such as DBeaver, works fine. Good idea @Colin'tHart, I will ask the mailing list
    – JGH
    Jun 16, 2020 at 13:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.