hledger-lib-1.14.1: Core data types, parsers and functionality for the hledger accounting tools

Safe HaskellSafe
LanguageHaskell2010

Hledger.Utils.UTF8IOCompat

Description

UTF-8 aware string IO functions that will work across multiple platforms and GHC versions. Includes code from Text.Pandoc.UTF8 ((C) 2010 John MacFarlane).

Example usage:

import Prelude hiding (readFile,writeFile,appendFile,getContents,putStr,putStrLn) import UTF8IOCompat (readFile,writeFile,appendFile,getContents,putStr,putStrLn) import UTF8IOCompat (SystemString,fromSystemString,toSystemString,error',userError')

2013410 update: we now trust that current GHC versions & platforms do the right thing, so this file is a no-op and on its way to being removed. Not carefully tested.

Synopsis

Documentation

readFile :: FilePath -> IO String #

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

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

getContents :: IO String #

hGetContents :: Handle -> IO String #

putStr :: String -> IO () #

putStrLn :: String -> IO () #

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

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

type SystemString = String Source #

A string received from or being passed to the operating system, such as a file path, command-line argument, or environment variable name or value. With GHC versions before 7.2 on some platforms (posix) these are typically encoded. When converting, we assume the encoding is UTF-8 (cf http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html#UTF8).

fromSystemString :: SystemString -> String Source #

Convert a system string to an ordinary string, decoding from UTF-8 if it appears to be UTF8-encoded and GHC version is less than 7.2.

toSystemString :: String -> SystemString Source #

Convert a unicode string to a system string, encoding with UTF-8 if we are on a posix platform with GHC < 7.2.

error' :: String -> a Source #

A SystemString-aware version of error.

userError' :: String -> IOError Source #

A SystemString-aware version of userError.

usageError :: String -> a Source #

A SystemString-aware version of error that adds a usage hint.