| Portability | tested on GHC only |
|---|---|
| Stability | experimental |
| Maintainer | Simon Meier <iridcode@gmail.com> |
Blaze.ByteString.Builder.Char.Utf8
Contents
Writing UTF-8 encoded characters to a buffer
writeChar :: Char -> WriteSource
Write a UTF-8 encoded Unicode character to a buffer.
Note that the control flow of writeChar is more complicated than the one
of writeWord8, as the size of the write depends on the Char written.
Therefore,
fromWrite $ writeChar a `mappend` writeChar b
must not always be faster than
fromChar a `mappend` fromChar b
Use benchmarking to make informed decisions.
Creating Builders from UTF-8 encoded characters
fromString :: String -> BuilderSource
O(n). Serialize a Unicode String using the UTF-8 encoding.
fromText :: Text -> BuilderSource
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 TL.encodeUtf8
is strict.
fromLazyText :: Text -> BuilderSource
O(n). Serialize a lazy Unicode Text value using the UTF-8 encoding.
Note that this function is currently faster than TL.encodeUtf8 provided by
Data.Text.Lazy.Encoding.