ghc-lib-parser-9.8.5.20250214: The GHC API, decoupled from GHC versions
Safe HaskellIgnore
LanguageHaskell2010

GHC.Utils.Encoding.UTF8

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

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

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.