0

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?

Arii
  • 349
  • 2
  • 10
  • Oops, duplicate of [this](https://stackoverflow.com/q/66928909/9422370), voting to close... – Arii Dec 30 '22 at 22:18
  • It's definitely very much a Windows-specific issue. – leftaroundabout Dec 31 '22 at 00:18
  • Generally, please paste your actual, exact code. Here you've written `main withUtf8`, while your compiling code presumably reads `main = withUtf8`. Of course, that mistake is easy to fix, but when your code snippet obviously doesn't match the behavior you're describing, question answerers will wonder if you transcribed anything else wrong too. – amalloy Jan 01 '23 at 05:22

0 Answers0