on master help sign in
Merge pull request #3656 from RyanGlScott/master

Run Idris in a UTF-8-compatible codepage on Windows

commit6f46ba0e39bc292734d2cf0339464546c9f5ec07 authorNiklas Larsson <metaniklas@gmail.com> dateMon 13 Feb 2017, 17:10 (10 years ago) parentbc553c7e25c2ed
4 files changed+17−8
CHANGELOG.md+4 idris.cabal+1 src/Idris/ErrReverse.hs+2−2 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/ErrReverse.hs+2−2
@@ -10,8 +10,8 @@ Maintainer : The Idris Community.
1010module Idris.ErrReverse(errReverse) where
1111
1212import Idris.AbsSyntax
13+import Idris.Core.Evaluate (unfold)
1314import Idris.Core.TT
14−import Idris.Core.Evaluate(unfold)
1515import Util.Pretty
1616
1717import Data.List
@@ -26,7 +26,7 @@ errReverse ist t = rewrite 5 (do_unfold t) -- (elideLambdas t)
2626 do_unfold :: Term -> Term
2727 do_unfold t = let ns = idris_errReduce ist in
2828 if null ns then t
29− else unfold (tt_ctxt ist) []
29+ else unfold (tt_ctxt ist) []
3030 (map (\x -> (x, 1000)) (idris_errReduce ist))
3131 t
3232
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;