@@ -0,0 +1,65 @@
2+Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
4+This program is free software; you can redistribute it and/or modify
5+it under the terms of the GNU General Public License as published by
6+the Free Software Foundation; either version 2 of the License, or
7+(at your option) any later version.
9+This program is distributed in the hope that it will be useful,
10+but WITHOUT ANY WARRANTY; without even the implied warranty of
11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+GNU General Public License for more details.
14+You should have received a copy of the GNU General Public License
15+along with this program; if not, write to the Free Software
16+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+ Module : Text.Pandoc.UTF8
21+ Copyright : Copyright (C) 2010 John MacFarlane
22+ License : GNU GPL, version 2 or above
24+ Maintainer : John MacFarlane <jgm@berkeley.edu>
26+ Portability : portable
28+UTF-8 aware string IO functions that will work with GHC 6.10 or 6.12.
30+module Text.Pandoc.UTF8 ( readFile
40+import qualified Data.ByteString.Lazy as B
41+import Data.ByteString.Lazy.UTF8 (toString, fromString)
42+import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
43+import System.IO (Handle)
44+import Control.Monad (liftM)
46+readFile :: FilePath -> IO String
47+readFile = liftM toString . B.readFile
49+writeFile :: FilePath -> String -> IO ()
50+writeFile f = B.writeFile f . fromString
52+getContents :: IO String
53+getContents = liftM toString B.getContents
55+putStr :: String -> IO ()
56+putStr = B.putStr . fromString
58+putStrLn :: String -> IO ()
59+putStrLn = B.putStrLn . fromString
61+hPutStr :: Handle -> String -> IO ()
62+hPutStr h = B.hPutStr h . fromString
64+hPutStrLn :: Handle -> String -> IO ()
65+hPutStrLn h s = hPutStr h (s ++ "\n")