@@ -0,0 +1,65 @@
1+{-
2+Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
3+
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.
8+
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.
13+
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
17+-}
18+
19+{- |
20+ Module : Text.Pandoc.UTF8
21+ Copyright : Copyright (C) 2010 John MacFarlane
22+ License : GNU GPL, version 2 or above
23+
24+ Maintainer : John MacFarlane <jgm@berkeley.edu>
25+ Stability : alpha
26+ Portability : portable
27+
28+UTF-8 aware string IO functions that will work with GHC 6.10 or 6.12.
29+-}
30+module Text.Pandoc.UTF8 ( readFile
31+ , writeFile
32+ , getContents
33+ , putStr
34+ , putStrLn
35+ , hPutStr
36+ , hPutStrLn
37+ )
38+
39+where
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)
45+
46+readFile :: FilePath -> IO String
47+readFile = liftM toString . B.readFile
48+
49+writeFile :: FilePath -> String -> IO ()
50+writeFile f = B.writeFile f . fromString
51+
52+getContents :: IO String
53+getContents = liftM toString B.getContents
54+
55+putStr :: String -> IO ()
56+putStr = B.putStr . fromString
57+
58+putStrLn :: String -> IO ()
59+putStrLn = B.putStrLn . fromString
60+
61+hPutStr :: Handle -> String -> IO ()
62+hPutStr h = B.hPutStr h . fromString
63+
64+hPutStrLn :: Handle -> String -> IO ()
65+hPutStrLn h s = hPutStr h (s ++ "\n")