git.iko.soy/typeable/pandoc
on master help sign in
Revert "Use local encoding for input/output rather than forcing UTF8."

This reverts commit c69837adb648a479167be5e2d37279a02be8060c.

commitf67333696bc7f6e76ca7b91d8677ce709502e212 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 23 Sep 2012, 12:33 (14 years ago) parentc69837a
2 files changed+13−12
src/Text/Pandoc/Parsing.hs+2−1 src/pandoc.hs+11−11
src/Text/Pandoc/Parsing.hs+2−1
@@ -146,6 +146,7 @@ where
146146import Text.Pandoc.Definition
147147import Text.Pandoc.Options
148148import Text.Pandoc.Builder (Blocks)
149+import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
149150import Text.Parsec
150151import Text.Parsec.Pos (newPos)
151152import Data.Char ( toLower, toUpper, ord, isAscii, isAlphaNum, isDigit, isPunctuation )
@@ -707,7 +708,7 @@ readWith parser state input =
707708testStringWith :: (Show a) => Parser [Char] ParserState a
708709 -> String
709710 -> IO ()
710−testStringWith parser str = putStrLn $ show $
711+testStringWith parser str = UTF8.putStrLn $ show $
711712 readWith parser defaultParserState str
712713
713714-- | Parsing options.
src/pandoc.hs+11−11
@@ -363,7 +363,7 @@ options =
363363 , Option "H" ["include-in-header"]
364364 (ReqArg
365365 (\arg opt -> do
366− text <- readFile arg
366+ text <- UTF8.readFile arg
367367 -- add new ones to end, so they're included in order specified
368368 let newvars = optVariables opt ++ [("header-includes",text)]
369369 return opt { optVariables = newvars,
@@ -374,7 +374,7 @@ options =
374374 , Option "B" ["include-before-body"]
375375 (ReqArg
376376 (\arg opt -> do
377− text <- readFile arg
377+ text <- UTF8.readFile arg
378378 -- add new ones to end, so they're included in order specified
379379 let newvars = optVariables opt ++ [("include-before",text)]
380380 return opt { optVariables = newvars,
@@ -385,7 +385,7 @@ options =
385385 , Option "A" ["include-after-body"]
386386 (ReqArg
387387 (\arg opt -> do
388− text <- readFile arg
388+ text <- UTF8.readFile arg
389389 -- add new ones to end, so they're included in order specified
390390 let newvars = optVariables opt ++ [("include-after",text)]
391391 return opt { optVariables = newvars,
@@ -528,7 +528,7 @@ options =
528528 , Option "" ["epub-stylesheet"]
529529 (ReqArg
530530 (\arg opt -> do
531− text <- readFile arg
531+ text <- UTF8.readFile arg
532532 return opt { optEPUBStylesheet = Just text })
533533 "FILENAME")
534534 "" -- "Path of epub.css"
@@ -544,7 +544,7 @@ options =
544544 , Option "" ["epub-metadata"]
545545 (ReqArg
546546 (\arg opt -> do
547− text <- readFile arg
547+ text <- UTF8.readFile arg
548548 return opt { optEPUBMetadata = text })
549549 "FILENAME")
550550 "" -- "Path of epub metadata file"
@@ -756,7 +756,7 @@ defaultWriterName x =
756756main :: IO ()
757757main = do
758758
759− rawArgs <- liftM (map UTF8.decodeArg) getArgs
759+ rawArgs <- liftM (map decodeArg) getArgs
760760 prg <- getProgName
761761 let compatMode = (prg == "hsmarkdown")
762762
@@ -888,7 +888,7 @@ main = do
888888 let tp' = case takeExtension tp of
889889 "" -> tp <.> format
890890 _ -> tp
891− E.catch (readFile tp')
891+ E.catch (UTF8.readFile tp')
892892 (\e -> if isDoesNotExistError e
893893 then E.catch
894894 (readDataFile datadir $
@@ -982,11 +982,11 @@ main = do
982982
983983 let readSources [] = mapM readSource ["-"]
984984 readSources srcs = mapM readSource srcs
985− readSource "-" = getContents
985+ readSource "-" = UTF8.getContents
986986 readSource src = case parseURI src of
987987 Just u | uriScheme u `elem` ["http:","https:"] ->
988988 readURI u
989− _ -> readFile src
989+ _ -> UTF8.readFile src
990990 readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
991991 return . toString -- treat all as UTF8
992992
@@ -1026,8 +1026,8 @@ main = do
10261026 writeBinary = B.writeFile (UTF8.encodePath outputFile)
10271027
10281028 let writerFn :: FilePath -> String -> IO ()
1029− writerFn "-" = putStr
1030− writerFn f = writeFile (UTF8.encodePath f)
1029+ writerFn "-" = UTF8.putStr
1030+ writerFn f = UTF8.writeFile f
10311031
10321032 case getWriter writerName' of
10331033 Left e -> err 9 e