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

Re: WIN32_CONSOLE usage

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Christoph Dalitz <christoph(dot)dalitz(at)hs-niederrhein(dot)de>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>,pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: WIN32_CONSOLE usage
Date: 2003-09-07 22:28:30
Message-ID: 200309072228.h87MSUT24579@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-cygwinpgsql-hackers-win32pgsql-patches
Christoph Dalitz wrote:
> On Sun, 7 Sep 2003 12:34:02 -0400 (EDT)
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> 
> > Peter Eisentraut wrote:
> > 
> > >   c) Problem:  8bit characters were displayed/interpreted wrong in psql
> > >                This is due to the fact that the Win32 "console" uses a
> > >                different encoding than the rest of the Windows system
> > >      Solution: Introduced a new psql variable WIN32_CONSOLE
> > >                When set with "\set WIN32_console", the function OemToChar()
> > 
> > > Bruce Momjian writes:
> > > 
> > > > Is this a valid feature?  Should I document it?
> > > 
> We have documented it and included a patch for the psql documentation.
> Was it applied?

Oh, sorry, I see it now.  It is already in CVS:

      <varlistentry>
        <term><varname>WIN32_CONSOLE</varname></term>
        <listitem>
        <para>
        This variable is only useful when working under the Win32 command
        console. As the Win32 command console uses a different encoding than
        the rest of the Windows system.  Eight-bit characters (e.g. German Umlauts)
        are corrupted. When this variable is set the command console encoding will
        be translated into ASCII encoding for input and output.
        </para>
        </listitem>
      </varlistentry>

I must have forgotten to do a case-insenstive grep.

> > > Maybe it's a valid feature, but the implementation is not valid.
> > > Other applications also make use of the print routines (e.g., createlang),
> > > and they cannot interactively set variables.  So I repeat: the print
> > > routines may not access the psql settings.
> > > 
> > > I think we ought to detect the console type automatically anyway.
> > > Certainly we don't want people to have to set this variables all the time.
> > 
> > Agreed.  Automatic is ideal.  Any ideas out there?
> > 
> Automatic detection does not work in all situation. The problem is a Microsoft
> insanity: the win32 "console" uses a different encoding *only on stdin and
> stdout*, not when accessing files. Thus it must be possible to set the parameter
> WIN32_CONSOLE manually. Sample psql session:
> 
>   psql> insert into tabelle values 'b?h';  -- here we need OemToChar()
>   psql> select * from tabelle;             -- here we need CharToOem()
>   psql> \i script.sql                      -- here CharToOem() must NOT be used
> 
> Note that this will not be observed in English speaking countries! The problem
> only occurs in other languages, which is the reason why most authors of win32
> software do not even know about this problem.
> 
> Another soulution would be, not to compile psql as a console application, but
> as a windows application and write an own terminal emulator. This solution
> however faces another win32 insanity: windows applications have no stdout.

Got it.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-cygwin by date

Next:From: Peter EisentrautDate: 2003-09-07 22:48:22
Subject: Re: WIN32_CONSOLE usage
Previous:From: Darko PrenosilDate: 2003-09-07 20:29:11
Subject: Re: [PATCHES] MinGW patch

pgsql-patches by date

Next:From: Peter EisentrautDate: 2003-09-07 22:48:22
Subject: Re: WIN32_CONSOLE usage
Previous:From: Bruce MomjianDate: 2003-09-07 22:26:00
Subject: Re: [HACKERS] Index creation takes for ever

pgsql-hackers-win32 by date

Next:From: Peter EisentrautDate: 2003-09-07 22:48:22
Subject: Re: WIN32_CONSOLE usage
Previous:From: Darko PrenosilDate: 2003-09-07 20:29:11
Subject: Re: [PATCHES] MinGW patch

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