Encode filenames as UTF8.
Resolves Issue #252 (pandoc doesn't properly handle unicode filenames).
This commit is contained in:
parent
6ccdde5571
commit
ca5217881d
2 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -54,7 +54,7 @@ import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
|
|||
import Network.URI (parseURI, isURI)
|
||||
import qualified Data.ByteString.Lazy as B
|
||||
import Data.ByteString.Lazy.UTF8 (toString, fromString)
|
||||
import Codec.Binary.UTF8.String (decodeString)
|
||||
import Codec.Binary.UTF8.String (decodeString, encodeString)
|
||||
|
||||
copyrightMessage :: String
|
||||
copyrightMessage = "\nCopyright (C) 2006-2010 John MacFarlane\n" ++
|
||||
|
@ -850,4 +850,4 @@ main = do
|
|||
|
||||
if outputFile == "-"
|
||||
then B.putStr writerOutput
|
||||
else B.writeFile outputFile writerOutput
|
||||
else B.writeFile (encodeString outputFile) writerOutput
|
||||
|
|
Loading…
Reference in a new issue