on master help sign in
Run Idris in a UTF-8-compatible codepage on Windows

Fixes #3000.

commit4a65355b94bb73597f2d51928c7cf863f13d6487 authorRyan Scott <ryan.gl.scott@gmail.com> dateSat 11 Feb 2017, 11:50 (10 years ago) parentbc553c7
3 files changed+15−6
CHANGELOG.md+4 idris.cabal+1 src/Idris/Main.hs+10−6
CHANGELOG.md+4
@@ -32,6 +32,10 @@
3232+ The REPL now colourises output on MinTTY consoles (e.g., Cygwin and MSYS)
3333 on Windows, which previously did not occur due to a bug.
3434
35++ Idris now runs in a UTF-8-compatible codepage on Windows. This fixes many
36+ Unicode-rendering issues on Windows (e.g., error messages stating
37+ `commitBuffer: invalid argument (invalid character)`).
38+
3539## Library Updates
3640
3741+ Terminating programs has been improved with more appropriate
idris.cabal+1
@@ -263,6 +263,7 @@ Library
263263 , blaze-markup >= 0.5.2.1 && < 0.9
264264 , bytestring < 0.11
265265 , cheapskate < 0.2
266+ , code-page >= 0.1 && < 0.2
266267 , containers >= 0.5 && < 0.6
267268 , deepseq < 1.5
268269 , directory >= 1.2.2.0 && < 1.2.3.0 || > 1.2.3.0
src/Idris/Main.hs+10−6
@@ -44,16 +44,20 @@ import System.Directory
4444import System.Exit
4545import System.FilePath
4646import System.IO
47+import System.IO.CodePage (withCP65001)
4748import Text.Trifecta.Result (ErrInfo(..), Result(..))
4849
4950-- | How to run Idris programs.
5051runMain :: Idris () -> IO ()
51−runMain prog = do res <- runExceptT $ execStateT prog idrisInit
52− case res of
53− Left err -> do
54− putStrLn $ "Uncaught error: " ++ show err
55− exitFailure
56− Right _ -> return ()
52+runMain prog = withCP65001 $ do
53+ -- Run in codepage 65001 on Windows so that UTF-8 characters can
54+ -- be displayed properly. See #3000.
55+ res <- runExceptT $ execStateT prog idrisInit
56+ case res of
57+ Left err -> do
58+ putStrLn $ "Uncaught error: " ++ show err
59+ exitFailure
60+ Right _ -> return ()
5761
5862-- | The main function of Idris that when given a set of Options will
5963-- launch Idris into the desired interaction mode either: REPL;