regional-pointers-0.1.0.2: Regional memory pointers

MaintainerBas van Dijk <v.dijk.bas@gmail.com>

Foreign.C.String.Region

Contents

Description

Lifts functions and types from Foreign.C.String to regional pointers.

Synopsis

Regional C Strings

type RegionalCString r = RegionalPtr CChar rSource

Handy type synonym for a regional pointer to an array of C characters terminated by a NUL.

This should provide a safer replacement for Foreign.C.String.CString.

type RegionalCStringLen r = (RegionalPtr CChar r, Int)Source

Handy type synonym for a regional pointer to an array of C characters which is paired with the length of the array instead of terminated by a NUL. (Thus allowing NUL characters in the middle of the string)

This should provide a safer replacement for Foreign.C.String.CStringLen.

Using a locale-dependent encoding

withCString :: MonadCatchIO pr => String -> (forall s. RegionalCString (RegionT s pr) -> RegionT s pr α) -> pr αSource

withCStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCStringLen (RegionT s pr) -> RegionT s pr α) -> pr αSource

Using 8-bit characters

castCharToCChar :: Char -> CChar

Convert a Haskell character to a C character. This function is only safe on the first 256 characters.

castCCharToChar :: CChar -> Char

Convert a C byte, representing a Latin-1 character, to the corresponding Haskell character.

withCAString :: MonadCatchIO pr => String -> (forall s. RegionalCString (RegionT s pr) -> RegionT s pr α) -> pr αSource

withCAStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCStringLen (RegionT s pr) -> RegionT s pr α) -> pr αSource

C wide strings

type RegionalCWString r = RegionalPtr CWchar rSource

Handy type synonym for a regional pointer to an array of C wide characters terminated by a NUL.

This should provide a safer replacement for Foreign.C.String.CWString.

type RegionalCWStringLen r = (RegionalPtr CWchar r, Int)Source

Handy type synonym for a regional pointer to an array of C wide characters which is paired with the length of the array instead of terminated by a NUL. (Thus allowing NUL characters in the middle of the string)

This should provide a safer replacement for Foreign.C.String.CWStringLen.

withCWString :: MonadCatchIO pr => String -> (forall s. RegionalCWString (RegionT s pr) -> RegionT s pr α) -> pr αSource

withCWStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCWStringLen (RegionT s pr) -> RegionT s pr α) -> pr αSource