Data.Text.Internal.Encoding.Utf8

text-2.1.1: An efficient packed Unicode text type.

Copyright | (c) 2008 2009 Tom Harper (c) 2009 2010 Bryan O'Sullivan (c) 2009 Duncan Coutts (c) 2021 Andrew Lelechenko
License | BSD-style
Maintainer | bos@serpentine.com
Stability | experimental
Portability | GHC
Safe Haskell | None
Language | Haskell2010

Data.Text.Internal.Encoding.Utf8

Contents

- Validation
- Naive decoding

Description

Warning: this is an internal module, and does not have a stable API or name. Functions in this module may not check or enforce preconditions expected by public modules. Use at your own risk!

Basic UTF-8 validation and character manipulation.

Synopsis

- utf8Length :: Char -> Int
- utf8LengthByLeader :: Word8 -> Int
- ord2 :: Char -> (Word8, Word8)
- ord3 :: Char -> (Word8, Word8, Word8)
- ord4 :: Char -> (Word8, Word8, Word8, Word8)
- chr2 :: Word8 -> Word8 -> Char
- chr3 :: Word8 -> Word8 -> Word8 -> Char
- chr4 :: Word8 -> Word8 -> Word8 -> Word8 -> Char
- validate1 :: Word8 -> Bool
- validate2 :: Word8 -> Word8 -> Bool
- validate3 :: Word8 -> Word8 -> Word8 -> Bool
- validate4 :: Word8 -> Word8 -> Word8 -> Word8 -> Bool
- newtype DecoderState = DecoderState Word8
- utf8AcceptState :: DecoderState
- utf8RejectState :: DecoderState
- updateDecoderState :: Word8 -> DecoderState -> DecoderState
- data DecoderResult
  - = Accept !Char
  - | Incomplete !DecoderState !CodePoint
  - | Reject
- newtype CodePoint = CodePoint Int
- utf8DecodeStart :: Word8 -> DecoderResult
- utf8DecodeContinue :: Word8 -> DecoderState -> CodePoint -> DecoderResult

# Documentation

utf8Length :: Char -> Int Source #

Since: text-2.0

utf8LengthByLeader :: Word8 -> Int Source #

Since: text-2.0

ord2 :: Char -> (Word8, Word8) Source #

ord3 :: Char -> (Word8, Word8, Word8) Source #

ord4 :: Char -> (Word8, Word8, Word8, Word8) Source #

chr2 :: Word8 -> Word8 -> Char Source #

chr3 :: Word8 -> Word8 -> Word8 -> Char Source #

chr4 :: Word8 -> Word8 -> Word8 -> Word8 -> Char Source #

# Validation

validate1 :: Word8 -> Bool Source #

validate2 :: Word8 -> Word8 -> Bool Source #

validate3 :: Word8 -> Word8 -> Word8 -> Bool Source #

validate4 :: Word8 -> Word8 -> Word8 -> Word8 -> Bool Source #

# Naive decoding

newtype DecoderState Source #

Constructors

DecoderState Word8 |

#### Instances

Instances details

Show DecoderState Source # |
Instance details Defined in Data.Text.Internal.Encoding.Utf8 Methods showsPrec :: Int -> DecoderState -> ShowS # show :: DecoderState -> String # showList :: [DecoderState] -> ShowS #
Eq DecoderState Source # |
Instance details Defined in Data.Text.Internal.Encoding.Utf8 Methods (==) :: DecoderState -> DecoderState -> Bool Source # (/=) :: DecoderState -> DecoderState -> Bool Source #

utf8AcceptState :: DecoderState Source #

utf8RejectState :: DecoderState Source #

updateDecoderState :: Word8 -> DecoderState -> DecoderState Source #

data DecoderResult Source #

Since: text-2.0

Constructors

Accept !Char |
Incomplete !DecoderState !CodePoint |
Reject |

newtype CodePoint Source #

Constructors

CodePoint Int |

utf8DecodeStart :: Word8 -> DecoderResult Source #

Since: text-2.0

utf8DecodeContinue :: Word8 -> DecoderState -> CodePoint -> DecoderResult Source #

Since: text-2.0