For many Windows users, interesting characters like
● do not display properly in the console due to the various details and defaults of Windows, as reported here.
In the current release, characters like
✗ are turned into
X on Windows to make things look acceptable.
It seems like some languages (like Python?) have work arounds for getting the interesting characters to display better, but at this time, Haskell does not have something similar.
I periodically ask around in the Haskell IRC if anything has changed, and today I got some interesting information! I have distilled it into the following Haskell program:
import System.IO (hPutStrLn, hSetEncoding, stdout, utf8) import System.Win32.Console (setConsoleCP) chars :: String chars = "● ✗ ─ ┘ ┤ ┬ ↓" main :: IO () main = do putStrLn chars -- this should look bad! setConsoleCP 65001 -- weird fix for Windows? hSetEncoding stdout utf8 -- apparently this is needed? hPutStrLn stdout chars -- this may look okay?
- I have not tested this code!
- You will need to have the Win32 package installed, which gives access to SetConsoleCP.
- This program probably only compiles on Windows.
If you have Haskell set up on your Windows computer, can you try compiling and running this program? What is the output? I am hoping to see the first line look bad, and the second line look nice. But let me know whatever it is!
If you mess around with this, please ask any questions in the #elm-dev channel on Slack! I put a message there linking to this post, so we can talk on the subcomments of that. I want to keep this thread pretty clean, focusing on results like:
Using Windows 10 and cmd.exe it prints out:
ΓùÅ ΓùÅ ΓùÅ ΓùÅ ΓùÅ ΓùÅ ΓùÅ
● ✗ ─ ┘ ┤ ┬ ↓
Note: It is possible to make this code work cross platform with various weird Haskell things, but I wanted to avoid getting into that at this stage. Just want to confirm that we can get nice characters at this stage!