Blaze.ByteString.Builder.Char.Utf8

blaze-builder-0.2.1.4: Efficient buffered output.

Portability | tested on GHC only
Stability | experimental
Maintainer | Simon Meier <iridcode@gmail.com>
Safe Haskell | None

Blaze.ByteString.Builder.Char.Utf8

Contents

- Writing UTF-8 encoded characters to a buffer
- Creating Builders from UTF-8 encoded characters

Description

`Write`s and `Builder`s for serializing Unicode characters using the UTF-8 encoding.

Synopsis

- writeChar :: Char -> Write
- fromChar :: Char -> Builder
- fromString :: String -> Builder
- fromShow :: Show a => a -> Builder
- fromText :: Text -> Builder
- fromLazyText :: Text -> Builder

# Writing UTF-8 encoded characters to a buffer

writeChar :: Char -> Write

Write a UTF-8 encoded Unicode character to a buffer.

# Creating Builders from UTF-8 encoded characters

fromChar :: Char -> Builder

O(1). Serialize a Unicode character using the UTF-8 encoding.

fromString :: String -> Builder

O(n). Serialize a Unicode `String` using the UTF-8 encoding.

fromShow :: Show a => a -> Builder

O(n). Serialize a value by `Show`ing it and UTF-8 encoding the resulting `String`.

fromText :: Text -> Builder

O(n). Serialize a strict Unicode `Text` value using the UTF-8 encoding.

Note that this function is currently faster than `encodeUtf8` provided by Data.Text.Encoding. Moreover, `fromText` is also lazy, while `encodeUtf8` is strict.

fromLazyText :: Text -> Builder

O(n). Serialize a lazy Unicode `Text` value using the UTF-8 encoding.

Note that this function is currently faster than `encodeUtf8` provided by Data.Text.Lazy.Encoding.