quchen / prettyprinter

A modern, extensible and well-documented prettyprinter.
BSD 2-Clause "Simplified" License
293 stars 34 forks source link

Solving Windows building crash caused by symbols `»` and `«` in Deprecated pragma #220

Closed KovalevDima closed 2 years ago

KovalevDima commented 2 years ago

I've been trying to build prettyprinter as dhall dependency on Windows 11 and got an error commitAndReleaseBuffer: invalid argument (invalid character) while printing deprecated pragma text from module Prettyprinter.Render.Tutorials.StackMachineTutorial

module Prettyprinter.Render.Tutorials.StackMachineTutorial
    {-# DEPRECATED "Writing your own stack machine is probably more efficient and customizable; also consider using »renderSimplyDecorated(A)« instead" #-}
    where

After changing locale to ASCII via

chcp 437

problem was solved, but it was hard to understand what's going on. I haven't tried to locate problem by deleting this symbols and trying to build fork but I can't see another possible reasons for this error

sjakobi commented 2 years ago

Thanks for the report and the proposed fix!

If you use UTF-8 for the locale (chcp 65001), does the error still appear?

AFAIK UTF-8 is the "privileged" encoding in the context of GHC, although this isn't documented very well (http://downloads.haskell.org/~ghc/latest/docs/html/users_guide/separate_compilation.html?highlight=utf-8#haskell-source-files).

KovalevDima commented 2 years ago

My default chcp 866 causes this error. chcp 65001 works fine. Looks like it's specific problem of Russian Windows configuration. Maybe there is the same problem with configurations for other languages

KovalevDima commented 2 years ago

I didn't face such problems and didn't even know about CPs, since I built Haskell dependencies only on Linux before and never read about encodings. It was funny situation. After that i'll configure my Windows to avoid such problems in future

sjakobi commented 2 years ago

I'm glad that we could figure this out.

I'd prefer not to merge this PR because I think you'll run into a lot more encoding-related problems if you don't use a UTF-8 locale.

KovalevDima commented 2 years ago

Ok. Thank you!