on master help sign in
Run Idris in a UTF-8-compatible codepage on Windows
4a65355Ryan Scott
CHANGELOG.md+4
@@ -32,6 +32,10 @@
32+ The REPL now colourises output on MinTTY consoles (e.g., Cygwin and MSYS)
32+ The REPL now colourises output on MinTTY consoles (e.g., Cygwin and MSYS)
33 on Windows, which previously did not occur due to a bug.
33 on Windows, which previously did not occur due to a bug.
34
34
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+
35## Library Updates
39## Library Updates
36
40
37+ Terminating programs has been improved with more appropriate
41+ Terminating programs has been improved with more appropriate
idris.cabal+1
@@ -263,6 +263,7 @@ Library
263 , blaze-markup >= 0.5.2.1 && < 0.9
263 , blaze-markup >= 0.5.2.1 && < 0.9
264 , bytestring < 0.11
264 , bytestring < 0.11
265 , cheapskate < 0.2
265 , cheapskate < 0.2
266+ , code-page >= 0.1 && < 0.2
266 , containers >= 0.5 && < 0.6
267 , containers >= 0.5 && < 0.6
267 , deepseq < 1.5
268 , deepseq < 1.5
268 , directory >= 1.2.2.0 && < 1.2.3.0 || > 1.2.3.0
269 , 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
44import System.Exit
44import System.Exit
45import System.FilePath
45import System.FilePath
46import System.IO
46import System.IO
47+import System.IO.CodePage (withCP65001)
47import Text.Trifecta.Result (ErrInfo(..), Result(..))
48import Text.Trifecta.Result (ErrInfo(..), Result(..))
48
49
49-- | How to run Idris programs.
50-- | How to run Idris programs.
50runMain :: Idris () -> IO ()
51runMain :: Idris () -> IO ()
52+runMain prog = withCP65001 $ do
53+ -- Run in codepage 65001 on Windows so that UTF-8 characters can
54+ -- be displayed properly. See #3000.
51−runMain prog = do res <- runExceptT $ execStateT prog idrisInit
55+ res <- runExceptT $ execStateT prog idrisInit
52− case res of
56+ case res of
53− Left err -> do
57+ Left err -> do
54− putStrLn $ "Uncaught error: " ++ show err
58+ putStrLn $ "Uncaught error: " ++ show err
55− exitFailure
59+ exitFailure
56− Right _ -> return ()
60+ Right _ -> return ()
57
61
58-- | The main function of Idris that when given a set of Options will
62-- | The main function of Idris that when given a set of Options will
59-- launch Idris into the desired interaction mode either: REPL;
63-- launch Idris into the desired interaction mode either: REPL;