BUG #6510: A simple prompt is displayed using wrong charset

From: exclusion(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6510: A simple prompt is displayed using wrong charset
Date: 2012-03-03 18:44:37
Message-ID: E1S3twb-0004OY-4g@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-general pgsql-hackers

The following bug has been logged on the website:

Bug reference: 6510
Logged by: Alexander LAW
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 9.1.3
Operating system: Windows

I'm using postgresSQL in Windows with Russian locale and get unreadable
messages when the postgres utilities prompting me for input.
Please look at the screenshot:
(The psql writes the unreadable message prompting for the password.)
But at the same time the following message (WARINING) displayed right.

I believe it's related to setlocale and the difference between OEM and ANSI
encoding, which we had in Windows with the Russian locale.
The startup code of psql sets locale with the call setlocale(LC_ALL, "") and
MSDN documentation says that the call:
Sets the locale to the default, which is the user-default ANSI code page
obtained from the operating system.

After the call all the strings printed with the printf(stdout) will go
through the ANSI->OEM conversion.

But in the simple_prompt function strings written to con, and such writes go
without conversion.

I've made a little test to illustrate this:

#include "stdafx.h"
#include <locale.h>

int _tmain(int argc, _TCHAR* argv[])
setlocale(0, "");
fprintf(stdout, "ОК\n");
FILE * termin = fopen("con", "w");
fprintf(termin, "ОК\n");
return 0;

where "ОК" is "OK" with russian letters.
This test gives the following result:

The second line is readable, while the others are not.

If it can be helpful to understand the issue, I can perform another tests.

Thanks in advance,


Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2012-03-03 19:25:38 Re: Command Triggers, patch v11
Previous Message Kevin Grittner 2012-03-03 18:37:53 Re: Command Triggers, patch v11

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Vázquez 2012-03-03 20:22:16 Mix characters with utf-8 characters on the same query
Previous Message Scott Marlowe 2012-03-03 12:27:08 Re: Problems with non use of indexes

Browse pgsql-bugs by date

  From Date Subject
Next Message marko 2012-03-03 19:19:48 BUG #6511: calling spi_exec_query from non-main package, results in: couldn't fetch $_TD
Previous Message Claus Stadler 2012-03-03 11:29:18 Regression from 8.4 to 9.1.2/9.1.3: Optimizing filters on constants in unions