Using GHC(i) 9.2.5. (Thus, supposedly, after the fix mentioned here), trying to run the following snippet:
import Main.Utf8
import GHC.IO.Encoding (getLocaleEncoding)
main :: IO ()
main withUtf8 $ do
locale <- getLocaleEncoding
putStrLn $ show locale
putStrLn "ˢᵐᵃˡˡ"
(withUtf8
is from this library, just a utility to wrap setting encoding. I have tried every variation I can come up with of setting the encoding myself manually, with the only difference being that without it I either get garbled nonsense or an encoding error instead of ?????
)
The result is always
UTF-8
?????
This is running on a Windows tablet, initially with Alacritty wrapping MSYS, but I've tried on the MSYS terminal emulators, and with Windows PowerShell, and the effect is always the same. Additionally, the text isn't mangled when writing to a file instead of stdout, which leads me to believe it's not lying about the encoding. Furthermore, all my locale environment variables are UTF-8, echo "ˢᵐᵃˡˡ"
works fine, and I am able to run other command line programs and interpreters (node JS) without problem, so I'm fairly confident that the terminal(s) are perfectly capable of handling the output properly and it's uniquely GHC(i) that's messing this up. Using Text
instead of String
with UTF libraries has no impact.
This seems like it's probably a bug with GHC(i), but I've looked around their tracker and it seems like it's almost certainly already being talked about, and it doesn't honestly look like there's been all that much movement. So, in lieu of just giving them yet another ticket, is there any way that I can work around this and get unicode to properly print to stdout?