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

Julian Bradfield jcb at inf.ed.ac.uk
Fri Nov 5 18:21:26 UTC 2021


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.



More information about the Haskell-Cafe mailing list