@@ -18,25 +18,26 @@ import Flat.Instances.Util
1818-- >>> import qualified Data.Text as T
1919-- >>> import qualified Data.Text.Lazy as TL
2020-- >>> import Data.Word
21+ -- >>> tt t = let (ts,_,bs) = tst t in (ts,bs)
2122
22- {-|
23+ {- |
2324Text (and Data.Text.Lazy) is encoded as a byte aligned array of bytes corresponding to its UTF8 encoding.
2425
25- >>> tst $ T.pack ""
26- (True,16, [1,0])
26+ >>> tt $ T.pack ""
27+ (True,[1,0])
2728
28- >>> tst $ T.pack "aaa"
29- (True,120, [1,3,97,97,97,0])
29+ >>> tt $ T.pack "aaa"
30+ (True,[1,3,97,97,97,0])
3031
31- >>> tst $ T.pack "Β’Β’Β’"
32- (True,120, [1,6,194,162,194,162,194,162,0])
32+ >>> tt $ T.pack "Β’Β’Β’"
33+ (True,[1,6,194,162,194,162,194,162,0])
3334
34- >>> tst $ T.pack "ζ₯ζ₯ζ₯"
35- (True,120, [1,9,230,151,165,230,151,165,230,151,165,0])
35+ >>> tt $ T.pack "ζ₯ζ₯ζ₯"
36+ (True,[1,9,230,151,165,230,151,165,230,151,165,0])
3637
3738#ifndef ETA
38- >>> tst $ T.pack "πππ"
39- (True,120, [1,12,240,144,141,136,240,144,141,136,240,144,141,136,0])
39+ >>> tt $ T.pack "πππ"
40+ (True,[1,12,240,144,141,136,240,144,141,136,240,144,141,136,0])
4041#endif
4142
4243Strict and Lazy Text have the same encoding:
@@ -62,7 +63,7 @@ The default encoding is UTF8:
6263>>> tst (UTF8Text $ T.pack "ζ₯ζ₯ζ₯") == tst (T.pack "ζ₯ζ₯ζ₯")
6364True
6465-}
65- -- | A wrapper to encode/decode Text as UTF8 (slower but more compact)
66+ -- | A wrapper to encode/decode Text as UTF8
6667newtype UTF8Text = UTF8Text { unUTF8 :: T. Text} deriving (Eq ,Ord ,Show )
6768
6869instance Flat UTF8Text where
@@ -72,11 +73,11 @@ instance Flat UTF8Text where
7273
7374#if ! defined (ETA_VERSION) && ! defined (ETA)
7475{-|
75- >>> tst (UTF16Text $ T.pack "aaa")
76- (True,72, [1,6,97,0,97,0,97,0,0])
76+ >>> tt (UTF16Text $ T.pack "aaa")
77+ (True,[1,6,97,0,97,0,97,0,0])
7778
78- >>> tst (UTF16Text $ T.pack "πππ")
79- (True,120, [1,12,0,216,72,223,0,216,72,223,0,216,72,223,0])
79+ >>> tt (UTF16Text $ T.pack "πππ")
80+ (True,[1,12,0,216,72,223,0,216,72,223,0,216,72,223,0])
8081-}
8182
8283-- | A wrapper to encode/decode Text as UTF16
0 commit comments