Console codepage setting via chcp?

Corinna Vinschen
Thu Sep 24 15:43:00 GMT 2009

On Sep 24 13:29, Andy Koppe wrote:
> 2009/9/24 Corinna Vinschen:
> > 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.
> Agreed. Sorry for the pointless aside.

No worries.

Unfortunately there's another problem when utilizing the Console
codepage.  While testing I found that I was unable to switch the console
codepage to 932, even though the codepage 932 is installed, and
MultiByteToWideChar and WideCharToMultiByte both work fine using that
charset.  Same for 936, 949, and 950.  SetConsoleOutputCP() fails with

I asked on the microsoft newsgroup m.p.w.p.kernel and the replies
suggested that it's possible to use the codepages in the console only
when switching the system default locale to an appropriate language.

So I switched the default system locale to Japanese, rebooted, and when
starting my shell in a console window, my default codepage was set to
932.  Now I could use 932, but 936, 949, and 950 were still invalid.  So
I switched to Chinese, rebootedd and, voila, I was able to use codepage
950.  Then I switched back to English, rebooted and, voila, 932 and 950
were both invalid again.

Given that in the Japanese and Chinese locale all other singlebyte
codepages are still available, I have a hard time to understand the
scheme behind this.

Do you think this is a problem?  It's certainly an annoyance when
testing locale-specific changes, but is it relevant to users?

Last but not least, the alternative would be to store the Console
character set as an environment variable, just as the
"CYGWIN=codepage:[ansi:oem]" setting back in 1.5 times.  Sigh.


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

More information about the Cygwin-developers mailing list