ghc-boot-9.10.3: Shared functionality between GHC and its boot libraries

Safe Haskell | None
Language | Haskell2010

GHC.Utils.Encoding.UTF8

Contents

- Decoding single characters
- Decoding strings
- Counting characters
- Comparison
- Encoding strings

Description

Simple, non-streaming UTF-8 codecs.

This is one of several UTF-8 implementations provided by GHC; see Note [GHC's many UTF-8 implementations] in GHC.Encoding.UTF8 for an overview.

Synopsis

- utf8DecodeCharAddr# :: Addr# -> Int# -> (# Char#, Int# #)
- utf8DecodeCharPtr :: Ptr Word8 -> (Char, Int)
- utf8DecodeCharByteArray# :: ByteArray# -> Int# -> (# Char#, Int# #)
- utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8)
- utf8CharStart :: Ptr Word8 -> IO (Ptr Word8)
- utf8UnconsByteString :: ByteString -> Maybe (Char, ByteString)
- utf8DecodeByteString :: ByteString -> [Char]
- utf8DecodeShortByteString :: ShortByteString -> [Char]
- utf8DecodeForeignPtr :: ForeignPtr Word8 -> Int -> Int -> [Char]
- utf8DecodeByteArray# :: ByteArray# -> [Char]
- utf8CountCharsShortByteString :: ShortByteString -> Int
- utf8CountCharsByteArray# :: ByteArray# -> Int
- utf8CompareByteArray# :: ByteArray# -> ByteArray# -> Ordering
- utf8CompareShortByteString :: ShortByteString -> ShortByteString -> Ordering
- utf8EncodeByteArray# :: String -> ByteArray#
- utf8EncodePtr :: Ptr Word8 -> String -> IO ()
- utf8EncodeByteString :: String -> ByteString
- utf8EncodeShortByteString :: String -> ShortByteString
- utf8EncodedLength :: String -> Int

# Decoding single characters

utf8DecodeCharAddr# :: Addr# -> Int# -> (# Char#, Int# #) #

utf8DecodeCharPtr :: Ptr Word8 -> (Char, Int) #

utf8DecodeCharByteArray# :: ByteArray# -> Int# -> (# Char#, Int# #) #

utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8) Source #

Find the start of the codepoint preceding the codepoint at the given `Ptr`. This is undefined if there is no previous valid codepoint.

utf8CharStart :: Ptr Word8 -> IO (Ptr Word8) Source #

Find the start of the codepoint at the given `Ptr`. This is undefined if there is no previous valid codepoint.

utf8UnconsByteString :: ByteString -> Maybe (Char, ByteString) Source #

# Decoding strings

utf8DecodeByteString :: ByteString -> [Char] Source #

Decode a `ByteString` containing a UTF-8 string.

utf8DecodeShortByteString :: ShortByteString -> [Char] Source #

utf8DecodeForeignPtr :: ForeignPtr Word8 -> Int -> Int -> [Char] #

utf8DecodeByteArray# :: ByteArray# -> [Char] #

# Counting characters

utf8CountCharsShortByteString :: ShortByteString -> Int Source #

utf8CountCharsByteArray# :: ByteArray# -> Int #

# Comparison

utf8CompareByteArray# :: ByteArray# -> ByteArray# -> Ordering #

utf8CompareShortByteString :: ShortByteString -> ShortByteString -> Ordering Source #

# Encoding strings

utf8EncodeByteArray# :: String -> ByteArray# #

utf8EncodePtr :: Ptr Word8 -> String -> IO () #

utf8EncodeByteString :: String -> ByteString Source #

Encode a `String` into a `ByteString`.

utf8EncodeShortByteString :: String -> ShortByteString Source #

utf8EncodedLength :: String -> Int #