Skip to content

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

Description

@turbotimon

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)

Activity

  1. changed the title [-]BUG pretty not working on windows "invalid character"[/-] [+]BUG pretty not working on Windows: "invalid character"[/+] on May 11, 2023
  2. sjakobi commented on May 11, 2023

    @sjakobi
    Collaborator

    What happens if you just input "hello λ"?

    Did you configure your terminal to use UTF-8?

  3. turbotimon commented on May 15, 2023

    @turbotimon
    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.

  4. turbotimon commented on May 31, 2023

    @turbotimon
    Author

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

    (this link may be also useful)

  5. das-g commented on May 31, 2023

    @das-g

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

  6. sjakobi commented on Nov 30, 2025

    @sjakobi
    Collaborator

    I'm not sure that prettyprinter should try to set encodings on Windows.

    Maybe we can add a bit of documentation about this though. Where would you expect to find it?

  7. turbotimon commented on Dec 1, 2025

    @turbotimon
    Author

    Probably on the main page / readme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions