ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Utils.Encoding.UTF8

Contents

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

Description

Simple, non-streaming Modified 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# #) Source #

Decode a single character at the given `Addr#`.

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

Decode a single codepoint starting at the given `Ptr`.

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

Decode a single codepoint starting at the given byte offset into a `ByteArray#`.

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

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

# Counting characters

utf8CountCharsShortByteString :: ShortByteString -> Int Source #

utf8CountCharsByteArray# :: ByteArray# -> Int Source #

# Comparison

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

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

# Encoding strings

utf8EncodeByteArray# :: String -> ByteArray# Source #

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

utf8EncodeByteString :: String -> ByteString Source #

Encode a `String` into a `ByteString`.

utf8EncodeShortByteString :: String -> ShortByteString Source #

utf8EncodedLength :: String -> Int Source #