Skip to content

Commit

Permalink
Properly handle UTF-8 in config files.
Browse files Browse the repository at this point in the history
  • Loading branch information
John MacFarlane committed Dec 19, 2009
1 parent 13b66f4 commit f35e2c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Network/Gitit/Config.hs
Expand Up @@ -36,7 +36,7 @@ import System.Environment
import System.Exit
import System.IO (stdout, stderr)
import System.Console.GetOpt
import Data.ConfigFile
import Data.ConfigFile hiding (readfile)
import Control.Monad.Error
import System.Log.Logger ()
import Data.List (intercalate)
Expand Down Expand Up @@ -101,6 +101,15 @@ compileInfo =
forceEither :: Show e => Either e a -> a
forceEither = either (error . show) id

-- | A version of readfile that treats the file as UTF-8.
readfile :: MonadError CPError m
=> ConfigParser
-> FilePath
-> IO (m ConfigParser)
readfile cp path' = do
contents <- readFile path'
return $ readstring cp contents

handleFlag :: ConfigParser -> Config -> Opt -> IO Config
handleFlag cp conf opt = do
progname <- getProgName
Expand Down

0 comments on commit f35e2c5

Please sign in to comment.