Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use utf-8 codepage on Windows #16

Open
Sorokin-Anton opened this issue Nov 10, 2022 · 0 comments
Open

Use utf-8 codepage on Windows #16

Sorokin-Anton opened this issue Nov 10, 2022 · 0 comments

Comments

@Sorokin-Anton
Copy link

Currently withUtf8 is not adding full utf-8 support on Windows, because we're not changing active codepage, and default one is not supporting utf-8 symbols.

Steps to reprouce:

Create a.hs with

import Main.Utf8
import System.IO.CodePage

main = do
	withUtf8 $ putStrLn "\9920"
	withUtf8 $ withCP65001 $ putStrLn "\9920"
	withCP65001 $ putStrLn "\9920"
	putStrLn "\9920"

and run it in cmd (my machine has Windows 10 installed).
Output is

?
⛀
⛀
a.hs: <stdout>: commitBuffer: invalid argument (invalid character)

so when default codepage is used, symbols are rendered as question marks.
When correct codepage is set, printing works with or without withUtf8
and when neither withCP65001 nor withUtf8 was used, there is error.

Suggestion

We can include withCP65001 to withUtf8. It makes printing user-friendly on Windows and does nothing on other systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant