Unicode windows console output.

Max Bolingbroke batterseapower at hotmail.com
Wed Nov 3 06:26:50 EDT 2010

On 2 November 2010 21:05, David Sankel <camior at gmail.com> wrote:
> Is there a ghc "wontfix" bug ticket for this? Perhaps we can make a small C
> test case and send it to the Microsoft people. Some[1] are reporting success
> with Unicode console output.

I confirmed that I can output Chinese unicode from Haskell. You can
test this by using a program like:

main = putStrLn "我学习电脑科学"

When you run it:
1. You need to use "chcp 65001" to set the console code page to UTF8
2. It is very likely that your Windows console won't have the fonts
required to actually make sense of the output. Pipe the output to
foo.txt. If you open this file in notepad you will see the correct
characters show up.

If you want to see the actual correct output in the console, there are
some more issues:
1. You need to do some registry hacking to use e.g. "SimSum Regular"
as the console font.
2. Even if you do this, my understanding is that it probably won't
work (you will still get junk output in the form of the actual UTF-8
bytes). I think you would instead need to use "chcp 936" (the
Simplified Chinese GBK code page) which tells the Windows API to
output GBK code points instead of the UTF-8 encoding. These should
then render correctly. However, to install the code page so chcp works
you need to have "East Asian language support" installed (so Windows 7
Professional users like me are out of luck, because it appears to have
been dropped in favour of "Language packs", which are only available
for 7 Ultimate/Enterprise...)

I don't know how all this would adapt to the lambda character. Maybe
you need to use a Greek code page?? And I have no idea where that
"permission denied" error is coming from.

In summary, this will probably never work properly. This sort of
rubbish is why I switched to OS X :-)


More information about the Glasgow-haskell-users mailing list