BUG #18439: No way to see national language error messages when running UTF8 scripts with psql.exe on Windows - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18439: No way to see national language error messages when running UTF8 scripts with psql.exe on Windows
Date
Msg-id 18439-f2f278cf3ffaac11@postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18439
Logged by:          Pavel Kulakov
Email address:      paul.kulakov@systematica.ru
PostgreSQL version: 15.3
Operating system:   Windows
Description:

Server has config parameter lc_messages=ru_RU.UTF-8

On Windows with default code page 1251 I run:

chcp 65001
set PGCLIENTENCODING=UTF8
psql --host=localhost --dbname=test --username=test --file=utf8file.sql

The file utf8file.sql is executed OK but if an error occurs psql shows error
message in incorrect encoding.
For example, if utf8file.sql contains string "select 1/0;" I see 

psql:utf8file.sql:1: ОШИБКА:  деление на ноль
instead of
psql:utf8file.sql:1: ОШИБКА:  деление на ноль

======================
Possible solutions:
1) The simplest one is to disable code page translation (CP_ACP ->
ConsoleOutputCP) for stderr (by new psql option?):
_setmode(_fileno(stderr), _O_BINARY);

Of course it will work only if CLIENT_ENCODING corresponds to
ConsoleOutputCP

2) Convert all incoming strings from current CLIENT_ENCODING to active code
page (CP_ACP) before output to console.
======================
Note: at the same time data (tables) output seems all right because of the
magic with pager pipe (indirect output).


pgsql-bugs by date:

Previous
From: Noah Misch
Date:
Subject: Re: relfrozenxid may disagree with row XIDs after 1ccc1e05ae
Next
From: PG Bug reporting form
Date:
Subject: BUG #18440: Query does not prune partitions correctly or use index when prepared statements are used