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

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

System.Glib.UTFString

Description

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

Synopsis

- class (IsString s, Monoid s, Show s) => GlibString s where
  - withUTFString :: s -> (CString -> IO a) -> IO a
  - withUTFStringLen :: s -> (CStringLen -> IO a) -> IO a
  - peekUTFString :: CString -> IO s
  - maybePeekUTFString :: CString -> IO (Maybe s)
  - peekUTFStringLen :: CStringLen -> IO s
  - newUTFString :: s -> IO CString
  - newUTFStringLen :: s -> IO CStringLen
  - genUTFOfs :: s -> UTFCorrection
  - stringLength :: s -> Int
  - unPrintf :: s -> s
- readUTFString :: GlibString s => CString -> IO s
- readCString :: CString -> IO String
- withUTFStrings :: GlibString s => [s] -> ([CString] -> IO a) -> IO a
- withUTFStringArray :: GlibString s => [s] -> (Ptr CString -> IO a) -> IO a
- withUTFStringArray0 :: GlibString s => [s] -> (Ptr CString -> IO a) -> IO a
- peekUTFStringArray :: GlibString s => Int -> Ptr CString -> IO [s]
- peekUTFStringArray0 :: GlibString s => Ptr CString -> IO [s]
- readUTFStringArray0 :: GlibString s => Ptr CString -> IO [s]
- data UTFCorrection
- ofsToUTF :: Int -> UTFCorrection -> Int
- ofsFromUTF :: Int -> UTFCorrection -> Int
- glibToString :: Text -> String
- stringToGlib :: String -> Text
- type DefaultGlibString = Text
- class fp ~ FilePath => GlibFilePath fp where
  - withUTFFilePath :: fp -> (CString -> IO a) -> IO a
  - peekUTFFilePath :: CString -> IO fp
- withUTFFilePaths :: GlibFilePath fp => [fp] -> ([CString] -> IO a) -> IO a
- withUTFFilePathArray :: GlibFilePath fp => [fp] -> (Ptr CString -> IO a) -> IO a
- withUTFFilePathArray0 :: GlibFilePath fp => [fp] -> (Ptr CString -> IO a) -> IO a
- peekUTFFilePathArray0 :: GlibFilePath fp => Ptr CString -> IO [fp]
- readUTFFilePathArray0 :: GlibFilePath fp => Ptr CString -> IO [fp]

# Documentation

class (IsString s, Monoid s, Show s) => GlibString s where Source #

Methods

withUTFString :: s -> (CString -> IO a) -> IO a Source #

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

withUTFStringLen :: s -> (CStringLen -> IO a) -> IO a Source #

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

peekUTFString :: CString -> IO s Source #

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

maybePeekUTFString :: CString -> IO (Maybe s) Source #

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

peekUTFStringLen :: CStringLen -> IO s Source #

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

newUTFString :: s -> IO CString Source #

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

newUTFStringLen :: s -> IO CStringLen Source #

Like Define newUTFStringLen to emit UTF-8.

genUTFOfs :: s -> UTFCorrection Source #

Create a list of offset corrections.

stringLength :: s -> Int Source #

Length of the string in characters

unPrintf :: s -> s Source #

#### Instances

Instances details

GlibString Text Source # |

Instance details

Defined in System.Glib.UTFString

Methods

withUTFString :: Text -> (CString -> IO a) -> IO a Source #

withUTFStringLen :: Text -> (CStringLen -> IO a) -> IO a Source #

peekUTFString :: CString -> IO Text Source #

maybePeekUTFString :: CString -> IO (Maybe Text) Source #

peekUTFStringLen :: CStringLen -> IO Text Source #

newUTFString :: Text -> IO CString Source #

newUTFStringLen :: Text -> IO CStringLen Source #

genUTFOfs :: Text -> UTFCorrection Source #

stringLength :: Text -> Int Source #

unPrintf :: Text -> Text Source #

GlibString [Char] Source # |

Instance details

Defined in System.Glib.UTFString

Methods

withUTFString :: [Char] -> (CString -> IO a) -> IO a Source #

withUTFStringLen :: [Char] -> (CStringLen -> IO a) -> IO a Source #

peekUTFString :: CString -> IO [Char] Source #

maybePeekUTFString :: CString -> IO (Maybe [Char]) Source #

peekUTFStringLen :: CStringLen -> IO [Char] Source #

newUTFString :: [Char] -> IO CString Source #

newUTFStringLen :: [Char] -> IO CStringLen Source #

genUTFOfs :: [Char] -> UTFCorrection Source #

stringLength :: [Char] -> Int Source #

unPrintf :: [Char] -> [Char] Source #

readUTFString :: GlibString s => CString -> IO s 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 :: GlibString s => [s] -> ([CString] -> IO a) -> IO a Source #

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

withUTFStringArray :: GlibString s => [s] -> (Ptr CString -> IO a) -> IO a Source #

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

withUTFStringArray0 :: GlibString s => [s] -> (Ptr CString -> IO a) -> IO a Source #

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

peekUTFStringArray :: GlibString s => Int -> Ptr CString -> IO [s] Source #

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

peekUTFStringArray0 :: GlibString s => Ptr CString -> IO [s] Source #

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

readUTFStringArray0 :: GlibString s => Ptr CString -> IO [s] 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

Instances details

Show UTFCorrection Source # |
Instance details Defined in System.Glib.UTFString Methods showsPrec :: Int -> UTFCorrection -> ShowS Source # show :: UTFCorrection -> String Source # showList :: [UTFCorrection] -> ShowS Source #

ofsToUTF :: Int -> UTFCorrection -> Int Source #

ofsFromUTF :: Int -> UTFCorrection -> Int Source #

glibToString :: Text -> String Source #

stringToGlib :: String -> Text Source #

type DefaultGlibString = Text Source #

class fp ~ FilePath => GlibFilePath fp where Source #

Methods

withUTFFilePath :: fp -> (CString -> IO a) -> IO a Source #

peekUTFFilePath :: CString -> IO fp Source #

#### Instances

Instances details

GlibFilePath FilePath Source # |
Instance details Defined in System.Glib.UTFString Methods withUTFFilePath :: FilePath -> (CString -> IO a) -> IO a Source # peekUTFFilePath :: CString -> IO FilePath Source #

withUTFFilePaths :: GlibFilePath fp => [fp] -> ([CString] -> IO a) -> IO a Source #

withUTFFilePathArray :: GlibFilePath fp => [fp] -> (Ptr CString -> IO a) -> IO a Source #

withUTFFilePathArray0 :: GlibFilePath fp => [fp] -> (Ptr CString -> IO a) -> IO a Source #

peekUTFFilePathArray0 :: GlibFilePath fp => Ptr CString -> IO [fp] Source #

readUTFFilePathArray0 :: GlibFilePath fp => Ptr CString -> IO [fp] Source #