@@ -46,8 +46,6 @@ where
46import Codec.Binary.UTF8.String (encodeString, decodeString)
46import Codec.Binary.UTF8.String (encodeString, decodeString)
49−#if MIN_VERSION_base(4,2,0)
51import System.IO hiding (readFile, writeFile, getContents,
49import System.IO hiding (readFile, writeFile, getContents,
52 putStr, putStrLn, hPutStr, hPutStrLn, hGetContents)
50 putStr, putStrLn, hPutStr, hPutStrLn, hGetContents)
53import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn )
51import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn )
@@ -79,48 +77,6 @@ hPutStrLn h s = hSetEncoding h utf8 >> IO.hPutStrLn h s
79hGetContents :: Handle -> IO String
77hGetContents :: Handle -> IO String
80hGetContents h = hSetEncoding h utf8_bom >> IO.hGetContents h
78hGetContents h = hSetEncoding h utf8_bom >> IO.hGetContents h
84−import qualified Data.ByteString as B
85−import Data.ByteString.UTF8 (toString, fromString)
86−import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
87−import System.IO (Handle)
88−import Control.Monad (liftM)
92−bom = B.pack [0xEF, 0xBB, 0xBF]
94−stripBOM :: B.ByteString -> B.ByteString
95−stripBOM s | bom `B.isPrefixOf` s = B.drop 3 s
98−readFile :: FilePath -> IO String
99−readFile = liftM (toString . stripBOM) . B.readFile . encodePath
101−writeFile :: FilePath -> String -> IO ()
102−writeFile f = B.writeFile (encodePath f) . fromString
104−getContents :: IO String
105−getContents = liftM (toString . stripBOM) B.getContents
107−hGetContents :: Handle -> IO String
108−hGetContents h = liftM (toString . stripBOM) (B.hGetContents h)
110−putStr :: String -> IO ()
111−putStr = B.putStr . fromString
113−putStrLn :: String -> IO ()
114−putStrLn = B.putStrLn . fromString
116−hPutStr :: Handle -> String -> IO ()
117−hPutStr h = B.hPutStr h . fromString
119−hPutStrLn :: Handle -> String -> IO ()
120−hPutStrLn h s = hPutStr h (s ++ "\n")
124encodePath :: FilePath -> FilePath
80encodePath :: FilePath -> FilePath
125decodeArg :: String -> String
81decodeArg :: String -> String
126#if MIN_VERSION_base(4,4,0)
82#if MIN_VERSION_base(4,4,0)