BUG #6510: A simple prompt is displayed using wrong charset - Mailing list pgsql-bugs

From exclusion@gmail.com
Subject BUG #6510: A simple prompt is displayed using wrong charset
Date
Msg-id E1S3twb-0004OY-4g@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #6510: A simple prompt is displayed using wrong charset
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      6510
Logged by:          Alexander LAW
Email address:      exclusion@gmail.com
PostgreSQL version: 9.1.3
Operating system:   Windows
Description:=20=20=20=20=20=20=20=20

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:
http://oi44.tinypic.com/aotje8.jpg
(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[])
{
    printf("=D0=9E=D0=9A\n");
    setlocale(0, "");
    fprintf(stdout, "=D0=9E=D0=9A\n");
    FILE * termin =3D fopen("con", "w");
    fprintf(termin, "=D0=9E=D0=9A\n");
    fflush(termin);
    return 0;
}

where "=D0=9E=D0=9A" is "OK" with russian letters.
This test gives the following result:
http://oi39.tinypic.com/35jgljs.jpg

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,
Alexander

pgsql-bugs by date:

Previous
From: Claus Stadler
Date:
Subject: Regression from 8.4 to 9.1.2/9.1.3: Optimizing filters on constants in unions
Next
From: Magnus Hagander
Date:
Subject: Re: BUG #6502: Missing Link at Version Tracker