text-2.1.1: An efficient packed Unicode text type.
LicenseBSD-style
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Text.IO.Utf8

Description

Efficient UTF-8 support for text I/O. Unlike Data.Text.IO, these functions do not depend on the locale and do not do line ending conversion.

Synopsis

File-at-a-time operations

readFile :: FilePath -> IO Text Source #

The readFile function reads a file and returns the contents of the file as a string. The entire file is read strictly, as with getContents.

writeFile :: FilePath -> Text -> IO () Source #

Write a string to a file. The file is truncated to zero length before writing begins.

appendFile :: FilePath -> Text -> IO () Source #

Write a string to the end of a file.

Operations on handles

hGetContents :: Handle -> IO Text Source #

Read the remaining contents of a Handle as a string.

hGetLine :: Handle -> IO Text Source #

Read a single line from a handle.

hPutStr :: Handle -> Text -> IO () Source #

Write a string to a handle.

hPutStrLn :: Handle -> Text -> IO () Source #

Write a string to a handle, followed by a newline.

Special cases for standard input and output

interact :: (Text -> Text) -> IO () Source #

The interact function takes a function of type Text -> Text as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.

getContents :: IO Text Source #

Read all user input on stdin as a single string.

getLine :: IO Text Source #

Read a single line of user input from stdin.

putStr :: Text -> IO () Source #

Write a string to stdout.

putStrLn :: Text -> IO () Source #

Write a string to stdout, followed by a newline.