glib-0.12.4: Binding to the GLIB library for Gtk2Hs.

Portability | portable (depends on GHC)
Stability | provisional
Maintainer | gtk2hs-users@lists.sourceforge.net
Safe Haskell | None

System.Glib.UTFString

Description

This module adds CString-like functions that handle UTF8 strings.

Synopsis

- withUTFString :: String -> (CString -> IO a) -> IO a
- withUTFStringLen :: String -> (CStringLen -> IO a) -> IO a
- newUTFString :: String -> IO CString
- newUTFStringLen :: String -> IO CStringLen
- peekUTFString :: CString -> IO String
- peekUTFStringLen :: CStringLen -> IO String
- maybePeekUTFString :: CString -> IO (Maybe String)
- readUTFString :: CString -> IO String
- readCString :: CString -> IO String
- withUTFStrings :: [String] -> ([CString] -> IO a) -> IO a
- withUTFStringArray :: [String] -> (Ptr CString -> IO a) -> IO a
- withUTFStringArray0 :: [String] -> (Ptr CString -> IO a) -> IO a
- peekUTFStringArray :: Int -> Ptr CString -> IO [String]
- peekUTFStringArray0 :: Ptr CString -> IO [String]
- readUTFStringArray0 :: Ptr CString -> IO [String]
- data UTFCorrection
- genUTFOfs :: String -> UTFCorrection
- ofsToUTF :: Int -> UTFCorrection -> Int
- ofsFromUTF :: Int -> UTFCorrection -> Int

# Documentation

withUTFString :: String -> (CString -> IO a) -> IO aSource

Like `withCString` but using the UTF-8 encoding.

withUTFStringLen :: String -> (CStringLen -> IO a) -> IO aSource

Like `withCStringLen` but using the UTF-8 encoding.

newUTFString :: String -> IO CString Source

Like `newCString` but using the UTF-8 encoding.

newUTFStringLen :: String -> IO CStringLen Source

Like Define newUTFStringLen to emit UTF-8.

peekUTFString :: CString -> IO String Source

Like `peekCString` but using the UTF-8 encoding.

peekUTFStringLen :: CStringLen -> IO String Source

Like `peekCStringLen` but using the UTF-8 encoding.

maybePeekUTFString :: CString -> IO (Maybe String)Source

Like `maybePeek` `peekCString` but using the UTF-8 encoding to retrieve UTF-8 from a `CString` which may be the `nullPtr`.

readUTFString :: CString -> IO String Source

Like like `peekUTFString` but then frees the string using g_free

readCString :: CString -> IO String Source

Like `peekCString` but then frees the string using `g_free`.

withUTFStrings :: [String] -> ([CString] -> IO a) -> IO aSource

Temporarily allocate a list of UTF-8 `CString`s.

withUTFStringArray :: [String] -> (Ptr CString -> IO a) -> IO aSource

Temporarily allocate an array of UTF-8 encoded `CString`s.

withUTFStringArray0 :: [String] -> (Ptr CString -> IO a) -> IO aSource

Temporarily allocate a null-terminated array of UTF-8 encoded `CString`s.

peekUTFStringArray :: Int -> Ptr CString -> IO [String]Source

Convert an array (of the given length) of UTF-8 encoded `CString`s to a list of Haskell `String`s.

peekUTFStringArray0 :: Ptr CString -> IO [String]Source

Convert a null-terminated array of UTF-8 encoded `CString`s to a list of Haskell `String`s.

readUTFStringArray0 :: Ptr CString -> IO [String]Source

Like `peekUTFStringArray0` but then free the string array including all strings.

To be used when functions indicate that their return value should be freed with `g_strfreev`.

data UTFCorrection Source

Offset correction for String to UTF8 mapping.

Instances

Show UTFCorrection |

genUTFOfs :: String -> UTFCorrection Source

Create a list of offset corrections.

ofsToUTF :: Int -> UTFCorrection -> Int Source

ofsFromUTF :: Int -> UTFCorrection -> Int Source