1
0
forked from GitHub/gf-core

Factor out code for setting the console encoding

Moved similar low-level code blocks in Main and GFI for setting the console
encoding to the new module GF.System.Console.
This commit is contained in:
hallgren
2012-10-05 12:54:49 +00:00
parent 2d371b7681
commit b5bf276e9c
4 changed files with 48 additions and 35 deletions

View File

@@ -1,4 +1,3 @@
{-# OPTIONS -cpp #-}
module Main where
import GFC
@@ -14,22 +13,11 @@ import System.Directory
import System.Environment (getArgs)
import System.Exit
import System.IO
#ifdef mingw32_HOST_OS
import System.Win32.Console
import System.Win32.NLS
#endif
import GF.System.Console (setConsoleEncoding)
main :: IO ()
main = do
#ifdef mingw32_HOST_OS
codepage <- getACP
setConsoleCP codepage
setConsoleOutputCP codepage
enc <- mkTextEncoding ("CP"++show codepage)
hSetEncoding stdin enc
hSetEncoding stdout enc
hSetEncoding stderr enc
#endif
setConsoleEncoding
args <- getArgs
case parseOptions args of
Ok (opts,files) -> do curr_dir <- getCurrentDirectory