GHC.Internal.Encoding.UTF8

ghc-internal-9.1400.0: Basic libraries

Copyright | (c) The University of Glasgow 1994-2023
License | see libraries/base/LICENSE
Maintainer | ghc-devs@haskell.org
Stability | internal
Portability | non-portable (GHC extensions)
Safe Haskell | None
Language | Haskell2010

GHC.Internal.Encoding.UTF8

Contents

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

Description

The API of this module is unstable and not meant to be consumed by the general public. If you absolutely must depend on it, make sure to use a tight upper bound, e.g., `base < 4.X` rather than `base < 5`, because the interface can change rapidly without much warning.

Simple UTF-8 codecs supporting non-streaming encoding/decoding. For encoding where codepoints may be broken across buffers, see GHC.IO.Encoding.UTF8.

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# #)
- utf8DecodeByteArray# :: ByteArray# -> [Char]
- utf8DecodeForeignPtr :: ForeignPtr Word8 -> Int -> Int -> [Char]
- utf8CountCharsByteArray# :: ByteArray# -> Int
- utf8CompareByteArray# :: ByteArray# -> ByteArray# -> Ordering
- utf8EncodePtr :: Ptr Word8 -> String -> IO ()
- utf8EncodeByteArray# :: String -> ByteArray#
- 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#`.

# Decoding strings

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

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

# Counting characters

utf8CountCharsByteArray# :: ByteArray# -> Int Source #

# Comparison

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

# Encoding strings

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

utf8EncodeByteArray# :: String -> ByteArray# Source #

utf8EncodedLength :: String -> Int Source #