delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/03/21/08:55:14

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 21 Mar 2011 13:54:33 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: cygwin + GetConsoleOutputCP
Message-ID: <20110321125433.GQ31220@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4D8651F2 DOT 3000200 AT cwilson DOT fastmail DOT fm> <AANLkTi=2pKTTo0+nUFa9Qaad7FxJwhhbQ5wJqtqtCpaw AT mail DOT gmail DOT com> <20110321111746 DOT GP31220 AT calimero DOT vinschen DOT de> <AANLkTimBFu3=4UCkKL=jraDLX00-MwhYpujm-vsRYsuc AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <AANLkTimBFu3=4UCkKL=jraDLX00-MwhYpujm-vsRYsuc@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Mar 21 12:37, Andy Koppe wrote:
> On 21 March 2011 11:17, Corinna Vinschen wrote:
> > to do the wrong thing anyway.  There are the following codepages available:
> >
> > - The current input console codepage, GetConsoleCP().
> >
> > - The current output console codepage, GetConsoleOutputCP().
> >
> > - The current OEM codepage, GetOEMCP().
> >
> > - The current ANSI codepage, GetACP().
> >
> > - The default OEM codepage of the default system locale,
> >  GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTCODEPAGE, ...).
> >
> > - The default ANSI codepage of the default system locale,
> >  GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE, ...).
> >
> > - The default OEM codepage of the current user or process,
> >  GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDEFAULTCODEPAGE, ...).
> >
> > - The default ANSI codepage of the current user or process,
> >  GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE, ...).
> >
> > - The default OEM codepage used for system invariant operations,
> >  GetLocaleInfo (LOCALE_INVARIANT, LOCALE_IDEFAULTCODEPAGE, ...).
> >
> > - The default ANSI codepage used for system invariant operations,
> >  GetLocaleInfo (LOCALE_INVARIANT, LOCALE_IDEFAULTANSICODEPAGE, ...).
> >
> > Which is the right one?
> 
> GetACP(), which "retrieves the current Windows ANSI code page
> identifier for the operating system". That's what programs using the
> non-Unicode APIs get. It's also the default in Notepad and other
> editors.

If you convert *to* a Windows codepage, it's a good choice.  If you
convert *from* Windows you never know if the file in question has
actually been stored in this codepage since you don't know of the
the file hasn't been generated by another user using another codepage.
Using GetACP() is ok, but it's still just guesswork.

> Other code pages would need to be specified explicitly by the user.
> 
> 
> > In theory the option is not useful and should just go away. If you
> > have to keep it for backward compatibility, stick to the current
> > behaviour and outlaw its use, perhaps be printing a nagging warning
> > to stderr.
> 
> ... and pointing them at iconv (which, to be fair, the -iso
> description already does).

And then there's the funny fact that a conversion iso-8859-1 to and
from cp1252 is basically a no-op anyway.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019