1
import qualified Data.ByteString as B
2
import qualified Data.ByteString.Lazy as BL
3
import qualified Data.Text as T
4
import qualified Data.Text.IO as T
5
import qualified Data.Text.Encoding as T
6
import qualified Data.Text.Lazy as TL
7
import qualified Data.Text.Lazy.Encoding as TL
8
import qualified Data.Text.Lazy.IO as TL
9
import qualified Codec.Binary.UTF8.Generic as U8
10
import Control.DeepSeq
11
import System.Environment
15
bs <- B.hGetContents h
16
rnf (T.decodeUtf8 bs) `seq` return ()
19
bs <- B.hGetContents h
20
print . T.length . T.decodeUtf8 $ bs
22
strict_init_len h = do
23
bs <- B.hGetContents h
24
print . T.length . T.init . T.decodeUtf8 $ bs
37
bs <- BL.hGetContents h
38
rnf (TL.decodeUtf8 bs) `seq` return ()
41
bs <- BL.hGetContents h
42
print . TL.length . TL.decodeUtf8 $ bs
45
bs <- BL.hGetContents h
46
print . TL.length . TL.init . TL.decodeUtf8 $ bs
50
t <- TL.hGetContents h
55
t <- TL.hGetContents h
68
lazy_string_utf8 h = do
69
bs <- BL.hGetContents h
70
let t = U8.toString bs
73
lazy_string_utf8_len h = do
74
bs <- BL.hGetContents h
75
let t = U8.toString bs
78
strict_string_utf8 h = do
79
bs <- B.hGetContents h
80
let t = U8.toString bs
83
strict_string_utf8_len h = do
84
bs <- B.hGetContents h
85
let t = U8.toString bs
89
[kind,name] <- getArgs
90
h <- openFile name ReadMode
93
"strict_len" -> strict_len h
94
"strict_init_len" -> strict_init_len h
95
"strict_io" -> strict_io h
96
"strict_len_io" -> strict_len_io h
98
"lazy_len" -> lazy_len h
99
"lazy_init_len" -> lazy_init_len h
100
"lazy_io" -> lazy_io h
101
"lazy_len_io" -> lazy_len_io h
103
"string_len" -> string_len h
104
"lazy_string_utf8" -> lazy_string_utf8 h
105
"lazy_string_utf8_len" -> lazy_string_utf8_len h
106
"strict_string_utf8" -> strict_string_utf8 h
107
"strict_string_utf8_len" -> strict_string_utf8_len h