PSQL console encoding - Mailing list pgsql-general

From Jean Gabriel
Subject PSQL console encoding
Date
Msg-id 601fb533-ec08-b485-d0e4-b401c3dd4830@GISspecialists.com
Whole thread Raw
List pgsql-general

Hello,

I am having some issues setting/using my PSQL console encoding to UTF-8 under Windows 10.

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 )).


select version();
                          version
------------------------------------------------------------
 PostgreSQL 12.1, compiled by Visual C++ build 1914, 64-bit


The DB is encoded as UTF8


show server_encoding;
 server_encoding
-----------------
 UTF8


The client_encoding is set to UTF8


 show client_encoding;
 client_encoding
-----------------
 UTF8


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


I nevertheless get the different code page warning when logging to my DB

psql (12.1)
WARNING: Console code page (65001) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.



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 apostrophechr
-----

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. The setting was recognized as the PSQL warning (Console code page (65001) differs from Windows code page (1252)) was not displayed anymore, but I still couldn't do   select 'é';

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"

So back to the question, is there a way of having a working UTF8 psql console?

Thank you,
Jean Gabriel

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: create batch script to import into postgres tables
Next
From: Pepe TD Vo
Date:
Subject: Re: create batch script to import into postgres tables