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!