GHC.Utils.Encoding.UTF8

ghc-lib-parser-9.10.1.20250103: 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 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# #) #

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

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

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

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

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

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

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

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

# Decoding strings

utf8DecodeByteString :: ByteString -> [Char] #

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

utf8DecodeShortByteString :: ShortByteString -> [Char] #

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

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

# Counting characters

utf8CountCharsShortByteString :: ShortByteString -> Int #

utf8CountCharsByteArray# :: ByteArray# -> Int #

# Comparison

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

utf8CompareShortByteString :: ShortByteString -> ShortByteString -> Ordering #

# Encoding strings

utf8EncodeByteArray# :: String -> ByteArray# #

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

utf8EncodeByteString :: String -> ByteString #

Encode a `String` into a `ByteString`.

utf8EncodeShortByteString :: String -> ShortByteString #

utf8EncodedLength :: String -> Int #