glib-0.12.5.0: 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 a

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

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

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

newUTFString :: String -> IO CString

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

newUTFStringLen :: String -> IO CStringLen

Like Define newUTFStringLen to emit UTF-8.

peekUTFString :: CString -> IO String

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

peekUTFStringLen :: CStringLen -> IO String

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

maybePeekUTFString :: CString -> IO (Maybe String)

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

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

readCString :: CString -> IO String

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

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

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

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

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

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

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

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

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]

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

readUTFStringArray0 :: Ptr CString -> IO [String]

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

Offset correction for String to UTF8 mapping.

Instances

Show UTFCorrection |

genUTFOfs :: String -> UTFCorrection

Create a list of offset corrections.

ofsToUTF :: Int -> UTFCorrection -> Int

ofsFromUTF :: Int -> UTFCorrection -> Int