[Haskell-cafe] How does GHC avoid "<stderr>: hPutChar: invalid argument (invalid character)"?

Merijn Verstraaten merijn at inconsistent.nl
Tue Apr 11 07:46:58 UTC 2017

This sounds to me like a classical case of a wrongly (or not) configured locale/terminal. As a starting point I would check both what the locale variables are set to (run "locale" in the shell) and check what encoding the terminal is set to. I've noticed a lot of linux installs have completely borked configuration with regards to these and in those cases GHC can't do much.

Side note: Just forcing output to be utf8 is *definitely* the wrong thing to do, as it'd break any environment set to a different encoding...


> On 11 Apr 2017, at 1:24, Yuji Yamamoto <whosekiteneverfly at gmail.com> wrote:
> Hello Haskellers,
> Currently, I’m working on this issue,
> where haddock crashes when printing the Unicode “bullet character” 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 the error?
> I couldn’t get it by reading the source of GHC a bit.
> Thanks in advance!
> _______________________________________________
> 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170411/84ed7616/attachment.sig>

More information about the Haskell-Cafe mailing list