System.Glib.UTFString

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

Maintainer | gtk2hs-users@lists.sourceforge.net
Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
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
- 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
- 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 #

Minimal complete definition

withUTFString, withUTFStringLen, peekUTFString, maybePeekUTFString, peekUTFStringLen, newUTFString, newUTFStringLen, genUTFOfs, stringLength, unPrintf

Methods

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

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

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

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

peekUTFString :: CString -> IO s #

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

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

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 #

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

newUTFString :: s -> IO CString #

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

newUTFStringLen :: s -> IO CStringLen #

Like Define newUTFStringLen to emit UTF-8.

genUTFOfs :: s -> UTFCorrection #

Create a list of offset corrections.

stringLength :: s -> Int #

Length of the string in characters

unPrintf :: s -> s #

Instances

GlibString Text # |
Methods withUTFString :: Text -> (CString -> IO a) -> IO a # withUTFStringLen :: Text -> (CStringLen -> IO a) -> IO a # peekUTFString :: CString -> IO Text # maybePeekUTFString :: CString -> IO (Maybe Text) # peekUTFStringLen :: CStringLen -> IO Text # newUTFString :: Text -> IO CString # newUTFStringLen :: Text -> IO CStringLen # genUTFOfs :: Text -> UTFCorrection # stringLength :: Text -> Int # unPrintf :: Text -> Text #
GlibString [Char] # |
Methods withUTFString :: [Char] -> (CString -> IO a) -> IO a # withUTFStringLen :: [Char] -> (CStringLen -> IO a) -> IO a # peekUTFString :: CString -> IO [Char] # maybePeekUTFString :: CString -> IO (Maybe [Char]) # peekUTFStringLen :: CStringLen -> IO [Char] # newUTFString :: [Char] -> IO CString # newUTFStringLen :: [Char] -> IO CStringLen # genUTFOfs :: [Char] -> UTFCorrection # stringLength :: [Char] -> Int # unPrintf :: [Char] -> [Char] #

readUTFString :: GlibString s => CString -> IO s #

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

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

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

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

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

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

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

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] #

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] #

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 # |
Methods showsPrec :: Int -> UTFCorrection -> ShowS # show :: UTFCorrection -> String # showList :: [UTFCorrection] -> ShowS #

ofsToUTF :: Int -> UTFCorrection -> Int #

ofsFromUTF :: Int -> UTFCorrection -> Int #

glibToString :: Text -> String #

stringToGlib :: String -> Text #

type DefaultGlibString = Text #

class fp ~ FilePath => GlibFilePath fp where #

Minimal complete definition

withUTFFilePath, peekUTFFilePath

Methods

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

peekUTFFilePath :: CString -> IO fp #

Instances

GlibFilePath FilePath # |
Methods withUTFFilePath :: FilePath -> (CString -> IO a) -> IO a # peekUTFFilePath :: CString -> IO FilePath #

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] #