[Haskell-cafe] How does GHC avoid "<stderr>: hPutChar: invalid argument (invalid character)"?
whosekiteneverfly at gmail.com
Mon Apr 10 23:24:55 UTC 2017
Currently, I’m working on this issue
where haddock crashes when printing the Unicode “bullet character”
<http://www.fileformat.info/info/unicode/char/2022/index.htm> on stderr
whose character encoding is not UTF-8.
In the beforementioned pull request, I just added hSetEncoding stderr utf8
as a quick-and-dirty workaround.
But GHC actually doesn’t do so: GHC prints “?” instead of the bullet
character when stderr is not Unicode-compatible.
So, I believe there’s a better way to handle the case, and GHC knows it.
Then, how does GHC detect the handle’s character encoding and convert
incompatible characters (such as the bullet character) into “?” to avoid
I couldn’t get it by reading the source of GHC a bit.
Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe