| |||||||||||||||
| |||||||||||||||
Description | |||||||||||||||
Functions to convert various Unicode encodings into Haskell Strings (at present we only handle UTF-8, but we'd like to add UTF-16 and UTF-32). We assume that the UTF-8 encoded String is a list of Chars where, for each char c, 0 <= ord c <= 255. When we convert a Haskell String into a UTF-8 string, again the Chars in the resulting String are all codepoints from 0 to 255. | |||||||||||||||
Synopsis | |||||||||||||||
| |||||||||||||||
Documentation | |||||||||||||||
peekUTF8String :: CString -> IO String | |||||||||||||||
Analogous to peekCString. Converts UTF8 CString to String. | |||||||||||||||
newUTF8String :: String -> IO CString | |||||||||||||||
Analogous to newCString. Creates UTF8 encoded CString. | |||||||||||||||
withUTF8String :: String -> (CString -> IO a) -> IO a | |||||||||||||||
Analogous to withCString. Creates UTF8 encoded CString. | |||||||||||||||
withUTF8StringLen :: String -> (CStringLen -> IO a) -> IO a | |||||||||||||||
Analogous to withCStringLen. | |||||||||||||||
toUTF8 :: String -> String | |||||||||||||||
Converts a String into its UTF8 representation. | |||||||||||||||
fromUTF8 :: Monad m => String -> m String | |||||||||||||||
We really want a fromUTF8 that will do error recovery i.e. it will never raise an error, and do the best job it can, inserting substitution characters where necessary. But for now we'll just pretend... | |||||||||||||||
fromUTF8E :: String -> Either String String | |||||||||||||||
Instance of Control.Monad.MonadError, as suggested below. | |||||||||||||||
fromUTF8WE :: Monad m => String -> m String | |||||||||||||||
Converts a UTF8 representation of a String back into the String, catching all possible format errors. Example: With the Haskell module Control.Monad.Error, you can instance this as (fromUTF8WE :: String -> Either String String) to get a conversion function which either succeeds (Right) or returns an error message (Left). | |||||||||||||||
Produced by Haddock version 0.7 |