This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: Console codepage setting via chcp?
On Sep 23 20:57, Andy Koppe wrote:
> 2009/9/23 Corinna Vinschen:
> > After so many months of looking into the charset stuff it occured to me
> > just a few minutes ago, that there was *always* a way to switch the
> > codepage of the console in a fixed manner: chcp.
>
> Hmm, I note it even allows codepage 65001, aka UTF-8, including on XP.
It allows that at least since W2K, but AFAIR this also worked on NT4.
> (Which btw means that fhandler_console could go back to simply using
> "ANSI" console I/O functions and let Windows take care of the
> conversions. Except that CP20932 and eucJP aren't quite the same
> thing.)
No! We should not go back to using ANSI functions where we already
converted to Unicode. The trick is that the actual codepage setting
of the console doesn't really matter. It's just a neat trick to
store the information somewhere which is under control of the user.
When using Unicode functions, the output codepage 1234 is just a number
for me. What 1234 means is entirely under control of Cygwin.
Therefore, if you switch to codepage 20932, this is EUC-JP for
Cygwin, but it is *Cygwin's* implementation of EUC-JP, not Windows'.
> > My question is, what do you all think? Isn't that a much better
> > controllable setting then how it's done now?
>
> I agree in principle.
Cool.
> > The only downside from my point of view is that the user has to know the
> > codepage numbers.
>
> Yes, there's that, and something else: LC_CTYPE (or LANG or LC_ALL)
> has to be in sync with the console/terminal's setting, so that
> applications that do care about them (i.e., most) work correctly.
>
> Mintty 0.5 does that by setting LANG according to the locale/charset
> fields in its options dialog, or by using the charset specified in the
> environment if nothing is set in the options.
>
> How could that be done for the console though? A couple of lines like
> this in cygwin.bat?
>
> chcp 65001
> set LC_CTYPE=C.UTF-8
Yes. Or use setfont/setcons/setcset/chcs:
setcons UTF-8
set LC_CTYPE=C.UTF-8
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat