utf8-string-0.3.8: Support for reading and writing UTF8 Strings

Copyright | (c) Eric Mertens 2007
License | BSD3-style (see LICENSE)
Maintainer | emertens@galois.com
Stability | experimental
Portability | portable
Safe Haskell | Trustworthy
Language | Haskell98

System.IO.UTF8

Description

String IO preserving UTF8 encoding.

Synopsis

- print :: Show a => a -> IO ()
- putStr :: String -> IO ()
- putStrLn :: String -> IO ()
- getLine :: IO String
- readLn :: Read a => IO a
- openBinaryFile :: FilePath -> IOMode -> IO Handle
- withBinaryFile :: FilePath -> IOMode -> (Handle -> IO a) -> IO a
- readFile :: FilePath -> IO String
- writeFile :: FilePath -> String -> IO ()
- appendFile :: FilePath -> String -> IO ()
- interact :: (String -> String) -> IO ()
- getContents :: IO String
- hGetLine :: Handle -> IO String
- hGetContents :: Handle -> IO String
- hPutStr :: Handle -> String -> IO ()
- hPutStrLn :: Handle -> String -> IO ()

# Documentation

print :: Show a => a -> IO ()

The `print` function outputs a value of any printable type to the standard output device. This function differs from the System.IO.print in that it preserves any UTF8 encoding of the shown value.

putStr :: String -> IO ()

Write a UTF8 string to the standard output device

putStrLn :: String -> IO ()

The same as `putStr`, but adds a newline character.

getLine :: IO String

Read a UTF8 line from the standard input device

readLn :: Read a => IO a

The `readLn` function combines `getLine` and `readIO`, preserving UTF8

openBinaryFile :: FilePath -> IOMode -> IO Handle

withBinaryFile :: FilePath -> IOMode -> (Handle -> IO a) -> IO a

readFile :: FilePath -> IO String

The `readFile` function reads a file and returns the contents of the file as a UTF8 string. The file is read lazily, on demand, as with `getContents`.

writeFile :: FilePath -> String -> IO ()

The computation `writeFile` `file str` function writes the UTF8 string `str`, to the file `file`.

appendFile :: FilePath -> String -> IO ()

The computation `appendFile` `file str` function appends the UTF8 string `str`, to the file `file`.

interact :: (String -> String) -> IO ()

getContents :: IO String

Lazily read stdin as a UTF8 string.

hGetLine :: Handle -> IO String

Read a UTF8 line from a Handle

hGetContents :: Handle -> IO String

Lazily read a UTF8 string from a Handle

hPutStr :: Handle -> String -> IO ()

Write a UTF8 string to a Handle.

hPutStrLn :: Handle -> String -> IO ()

Write a UTF8 string to a Handle, appending a newline.