[Haskell-cafe] printing unicode in Windows console: hPutChar error

Brandon Allbery allbery.b at gmail.com
Fri Nov 5 18:33:15 UTC 2021

What version of GHC areyour students using? I believe sufficiently
recent versions of ghc (but I don't know which; this may require
9.2.1) have an RTS option to use a new I/O manager, which among other
things implements the widechar API for console I/O. The old I/O
manager does not support the widechar API, and the best that can be
done is the chcp hack.

On Fri, Nov 5, 2021 at 2:24 PM Julian Bradfield <jcb at inf.ed.ac.uk> wrote:
> Some of my poor misguided students are still using Windows, and when
> they run my (predecessor's) Haskell program which uses Unicode box drawing
> characters in its output, they get
> *** Exception <stdout>: hPutChar: invalid argument (invalid character)
> Another student told them to change the console encoding via magic:
> chcp.com 65001
> but a bit of googling suggests that a "modern Windows console program"
> should be using the widechar API to print Unicode and things should
> Just Work.
> Does Haskell have a principled view about character encodings?
> Or does it just say "I do byte strings, it's the user's problem"?
> Decades ago I was all in favour of charset-agnosticism, but these
> days I tend to think "go Unicode, and leave the legacy Latin-1
> etc. data as the user's problem" :)
> Julian.
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

brandon s allbery kf8nh
allbery.b at gmail.com

More information about the Haskell-Cafe mailing list