Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-generalpgsql-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
Description:        

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("ОК\n");
    setlocale(0, "");
    fprintf(stdout, "ОК\n");
    FILE * termin = fopen("con", "w");
    fprintf(termin, "ОК\n");
    fflush(termin);
    return 0;
}

where "ОК" 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



Responses

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2012-03-03 19:25:38
Subject: Re: Command Triggers, patch v11
Previous:From: Kevin GrittnerDate: 2012-03-03 18:37:53
Subject: Re: Command Triggers, patch v11

pgsql-bugs by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group