This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygwin + GetConsoleOutputCP


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]