@@ -38,6 +38,7 @@ module Text.Pandoc.UTF8 ( readFile
3838
3939where
4040import qualified Data.ByteString as B
41+import Codec.Binary.UTF8.String (encodeString)
4142import Data.ByteString.UTF8 (toString, fromString)
4243import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
4344import System.IO (Handle)
@@ -51,10 +52,10 @@ stripBOM s | bom `B.isPrefixOf` s = B.drop 3 s
5152stripBOM s = s
5253
5354readFile :: FilePath -> IO String
54−readFile = liftM (toString . stripBOM) . B.readFile
55+readFile = liftM (toString . stripBOM) . B.readFile . encodeString
5556
5657writeFile :: FilePath -> String -> IO ()
57−writeFile f = B.writeFile f . fromString
58+writeFile f = B.writeFile (encodeString f) . fromString
5859
5960getContents :: IO String
6061getContents = liftM (toString . stripBOM) B.getContents