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

BUG pretty not working on Windows: "invalid character" #242

Open
turbotimon opened this issue May 11, 2023 · 4 comments
Open

BUG pretty not working on Windows: "invalid character" #242

turbotimon opened this issue May 11, 2023 · 4 comments

Comments

@turbotimon
Copy link

Prettyprinter does not work on Windows when printing a special character

ghci> import Prettyprinter
ghci> pretty "hello"
hello
ghci> pretty "hello λ"
hello *** Exception: <stdout>: hPutChar: invalid argument (invalid character)
  • Windows 10
  • Tested with PowerShell and CMD
  • prettyprinter-1.7.1 (stack snapshot lts-20.10)
@turbotimon turbotimon changed the title BUG pretty not working on windows "invalid character" BUG pretty not working on Windows: "invalid character" May 11, 2023
@sjakobi
Copy link
Collaborator

sjakobi commented May 11, 2023

What happens if you just input "hello λ"?

Did you configure your terminal to use UTF-8?

@turbotimon
Copy link
Author

I looks like UTF-8 generally work in PS and CMD. In GHCI it get's escaped (but no error):

PS C:\Users\user> "hello ?"
hello λ
PS C:\Users\user> ghci
GHCi, version 9.2.5: https://www.haskell.org/ghc/  :? for help
ghci> "hello λ"
"hello \955"

I know other people having this issue on windows, it therefore seems not to be a isolated problem with my system.

@turbotimon
Copy link
Author

turbotimon commented May 31, 2023

I found a workaround by changing the codepage of the PowerShell or cmd.exe: chcp 65001

(this link may be also useful)

@das-g
Copy link

das-g commented May 31, 2023

Here seems to be workaround that can probably be implemented in programs and libraries (rather than by the end user).

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

3 participants