ghc-boot-9.8.0.20230822: Shared functionality between GHC and its boot libraries
Safe HaskellNone
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# #) 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.

Decoding strings

utf8DecodeByteString :: ByteString -> [Char] Source #

Decode a ByteString containing a UTF-8 string.

Counting characters

Comparison

Encoding strings