hledger-lib-0.19: Core data types, parsers and utilities for the hledger accounting tool.

Safe HaskellSafe-Inferred



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')



type SystemString = StringSource

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 -> StringSource

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 -> SystemStringSource

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 -> aSource

A SystemString-aware version of error.

userError' :: String -> IOErrorSource

A SystemString-aware version of userError.