This is the mail archive of the cygwin-developers 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: Console codepage setting via chcp?


On Sep 23 20:17, Andy Koppe wrote:
> 2009/9/23 Corinna Vinschen:
> > Right now, if you switch the charset via the setlocale function, you
> > also switch the charset used for console output.
> 
> That's quite a unique advantage of the Cygwin console actually,
> because it means you always get correct output even if you switch
> charset on the fly.
> 
> A normal terminal, on the other hand, doesn't actually know what
> charset the app running inside it is using. Hence, for correct output,
> the user has to make sure the terminal and application charsets match,
> or use something like 'luit' to translate between them.

OTOH, two applications using different charsets potentially print the
same string differently on the same console.  That's quite puzzeling
sometimes.  I stumbled over this at least twice while looking into this
stuff yesterday and today.  I got an unexpected different result,
supposedly in the "C" locale, and only a while later I realized that I
had set $LANG to something non-"C" and only one of the apps used the
setlocale call.

> > ssh is always running in the "C" locale
> 
> Are you sure?

Yes, absolutely. 

>  Shouldn't it be calling 'setlocale(LC_ALL, "")', thereby
> configuring the console output according to the locale variables?

ssh simply doesn't need to set a locale.  It just sends byte streams
back and forth.  It doesn't give a dime for the content and it doesn't
care for the terminal it's running in.

This shows in a way that the current automatic console mode is not such
a good idea.  ssh doesn't care for that because in all other existing
terminals and terminal emulators it's not the application which decides
what charset the terminal uses, but the user who started the terminal.


Corinna

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


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