summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/UTF8.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-09-10 19:53:45 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2010-09-10 19:53:45 -0700
commitca5217881de1be672ac855a1979e9436aa6ced35 (patch)
tree61c81ac99623a98567d43f36cdc7fc8916b445cf /src/Text/Pandoc/UTF8.hs
parent6ccdde5571ff34a24c2daf969dbcd55126b43964 (diff)
Encode filenames as UTF8.
Resolves Issue #252 (pandoc doesn't properly handle unicode filenames).
Diffstat (limited to 'src/Text/Pandoc/UTF8.hs')
-rw-r--r--src/Text/Pandoc/UTF8.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
index 96d6e6218..eba79c734 100644
--- a/src/Text/Pandoc/UTF8.hs
+++ b/src/Text/Pandoc/UTF8.hs
@@ -38,6 +38,7 @@ module Text.Pandoc.UTF8 ( readFile
where
import qualified Data.ByteString as B
+import Codec.Binary.UTF8.String (encodeString)
import Data.ByteString.UTF8 (toString, fromString)
import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
import System.IO (Handle)
@@ -51,10 +52,10 @@ stripBOM s | bom `B.isPrefixOf` s = B.drop 3 s
stripBOM s = s
readFile :: FilePath -> IO String
-readFile = liftM (toString . stripBOM) . B.readFile
+readFile = liftM (toString . stripBOM) . B.readFile . encodeString
writeFile :: FilePath -> String -> IO ()
-writeFile f = B.writeFile f . fromString
+writeFile f = B.writeFile (encodeString f) . fromString
getContents :: IO String
getContents = liftM (toString . stripBOM) B.getContents