flat-0.6: Principled and efficient bit-oriented binary serialization.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Flat.Instances.Text

Description

Flat instances for the text library

Synopsis

Documentation

newtype UTF8Text Source #

The desired text encoding can be explicitly specified using the wrappers UTF8Text and UTF16Text.

The default encoding is UTF8:

>>> tst (UTF8Text $ T.pack "日日日") == tst (T.pack "日日日")
True

A wrapper to encode/decode Text as UTF8

Constructors

UTF8Text 

Fields

Instances

Instances details
Show UTF8Text Source # 
Instance details

Defined in Flat.Instances.Text

Flat UTF8Text Source # 
Instance details

Defined in Flat.Instances.Text

Eq UTF8Text Source # 
Instance details

Defined in Flat.Instances.Text

Ord UTF8Text Source # 
Instance details

Defined in Flat.Instances.Text

newtype UTF16Text Source #

>>> tt (UTF16Text $ T.pack "aaa")
(True,[1,6,97,0,97,0,97,0,0])
>>> tt (UTF16Text $ T.pack "𐍈𐍈𐍈")
(True,[1,12,0,216,72,223,0,216,72,223,0,216,72,223,0])

A wrapper to encode/decode Text as UTF16

Constructors

UTF16Text 

Fields

Orphan instances

Flat Text Source #

Text (and Data.Text.Lazy) is encoded as a byte aligned array of bytes corresponding to its UTF8 encoding.

>>> tt $ T.pack ""
(True,[1,0])
>>> tt $ T.pack "aaa"
(True,[1,3,97,97,97,0])
>>> tt $ T.pack "¢¢¢"
(True,[1,6,194,162,194,162,194,162,0])
>>> tt $ T.pack "日日日"
(True,[1,9,230,151,165,230,151,165,230,151,165,0])
>>> tt $ T.pack "𐍈𐍈𐍈"
(True,[1,12,240,144,141,136,240,144,141,136,240,144,141,136,0])

Strict and Lazy Text have the same encoding:

>>> tst (T.pack "abc") == tst (TL.pack "abc")
True
Instance details

Flat Text Source # 
Instance details