git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1994 from purescript/utf-logging

Use utf8 when writing to stdout and stderr

commitcf114621181c5e46dfa0de75385caf187f906091 authorPhil Freeman <paf31@cantab.net> dateSun 3 Apr 2016, 09:38 (11 years ago) parent904771dda0c6fe
4 files changed+21−48
psc-bundle/Main.hs+5−16 psc-docs/Main.hs+5−15 psc-publish/Main.hs+6−1 psc/Main.hs+5−16
psc-bundle/Main.hs+5−16
@@ -1,25 +1,12 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : psc-bundle
4−-- Copyright : (c) Phil Freeman 2015
5−-- License : MIT
6−--
7−-- Maintainer : Phil Freeman <paf31@cantab.net>
8−-- Stability : experimental
9−-- Portability :
10−--
11−-- | Bundles compiled PureScript modules for the browser.
12−--
13−-----------------------------------------------------------------------------
14−
151{-# LANGUAGE FlexibleContexts #-}
162{-# LANGUAGE ScopedTypeVariables #-}
173{-# LANGUAGE TupleSections #-}
184{-# LANGUAGE RecordWildCards #-}
195
6+-- | Bundles compiled PureScript modules for the browser.
207module Main (main) where
218
22−import Data.Maybe
9+import Data.Maybe
2310import Data.Traversable (for)
2411import Data.Version (showVersion)
2512
@@ -32,7 +19,7 @@ import Control.Monad.IO.Class
3219import System.FilePath (takeFileName, takeDirectory)
3320import System.FilePath.Glob (glob)
3421import System.Exit (exitFailure)
35−import System.IO (stderr, hPutStrLn)
22+import System.IO (stderr, stdout, hPutStrLn, hSetEncoding, utf8)
3623import System.Directory (createDirectoryIfMissing)
3724
3825import Language.PureScript.Bundle
@@ -125,6 +112,8 @@ options = Options <$> some inputFile
125112-- | Make it go.
126113main :: IO ()
127114main = do
115+ hSetEncoding stdout utf8
116+ hSetEncoding stderr utf8
128117 opts <- execParser (info (version <*> helper <*> options) infoModList)
129118 when (isJust (optionsRequirePath opts)) $ hPutStrLn stderr "The require-path option is deprecated and will be removed in PureScript 0.9."
130119 output <- runExceptT (app opts)
psc-docs/Main.hs+5−15
@@ -1,17 +1,4 @@
11{-# LANGUAGE TupleSections #-}
2−----------------------------------------------------------------------------
3−--
4−-- Module : Main
5−-- Copyright : (c) Phil Freeman 2013
6−-- License : MIT
7−--
8−-- Maintainer : Phil Freeman <paf31@cantab.net>
9−-- Stability : experimental
10−-- Portability :
11−--
12−-- |
13−--
14−-----------------------------------------------------------------------------
152
163module Main where
174
@@ -32,7 +19,7 @@ import qualified Text.PrettyPrint.ANSI.Leijen as PP
3219import qualified Language.PureScript as P
3320import qualified Paths_purescript as Paths
3421import System.Exit (exitFailure)
35−import System.IO (hPutStrLn, hPrint, stderr)
22+import System.IO (hPutStrLn, hPrint, hSetEncoding, stderr, stdout, utf8)
3623import System.Directory (createDirectoryIfMissing)
3724import System.FilePath (takeDirectory)
3825import System.FilePath.Glob (glob)
@@ -228,7 +215,10 @@ buildOptions (fmt, input, mapping) =
228215 exitFailure
229216
230217main :: IO ()
231−main = execParser opts >>= buildOptions >>= docgen
218+main = do
219+ hSetEncoding stdout utf8
220+ hSetEncoding stderr utf8
221+ execParser opts >>= buildOptions >>= docgen
232222 where
233223 opts = info (version <*> helper <*> pscDocsOptions) infoModList
234224 infoModList = fullDesc <> headerInfo <> footerInfo
psc-publish/Main.hs+6−1
@@ -7,6 +7,8 @@ import qualified Data.ByteString.Lazy.Char8 as BL
77
88import Options.Applicative hiding (str)
99
10+import System.IO (hSetEncoding, stderr, stdout, utf8)
11+
1012import qualified Paths_purescript as Paths
1113import Language.PureScript.Publish
1214import Language.PureScript.Publish.ErrorsWarnings
@@ -24,7 +26,10 @@ dryRunOptions = defaultPublishOptions
2426 where dummyVersion = ("0.0.0", Version [0,0,0] [])
2527
2628main :: IO ()
27−main = execParser opts >>= publish
29+main = do
30+ hSetEncoding stdout utf8
31+ hSetEncoding stderr utf8
32+ execParser opts >>= publish
2833 where
2934 opts = info (version <*> helper <*> dryRun) infoModList
3035 infoModList = fullDesc <> headerInfo <> footerInfo
psc/Main.hs+5−16
@@ -1,17 +1,3 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : Main
4−-- Copyright : (c) 2013-15 Phil Freeman, (c) 2014-15 Gary Burgess
5−-- License : MIT (http://opensource.org/licenses/MIT)
6−--
7−-- Maintainer : Phil Freeman <paf31@cantab.net>
8−-- Stability : experimental
9−-- Portability :
10−--
11−-- |
12−--
13−-----------------------------------------------------------------------------
14−
151{-# LANGUAGE DataKinds #-}
162{-# LANGUAGE FlexibleContexts #-}
173{-# LANGUAGE RecordWildCards #-}
@@ -34,7 +20,7 @@ import qualified Data.ByteString.UTF8 as BU8
3420import Options.Applicative as Opts
3521
3622import System.Exit (exitSuccess, exitFailure)
37−import System.IO (hPutStrLn, stderr)
23+import System.IO (hSetEncoding, hPutStrLn, stdout, stderr, utf8)
3824import System.IO.UTF8
3925import System.FilePath.Glob (glob)
4026
@@ -202,7 +188,10 @@ pscMakeOptions = PSCMakeOptions <$> many inputFile
202188 <*> jsonErrors
203189
204190main :: IO ()
205−main = execParser opts >>= compile
191+main = do
192+ hSetEncoding stdout utf8
193+ hSetEncoding stderr utf8
194+ execParser opts >>= compile
206195 where
207196 opts = info (version <*> helper <*> pscMakeOptions) infoModList
208197 infoModList = fullDesc <> headerInfo <> footerInfo