2-- Module : Data.Text.Lazy.Encoding
3-- Copyright : (c) Bryan O'Sullivan 2009
6-- Maintainer : bos@serpentine.com, rtharper@aftereternity.co.uk,
8-- Stability : experimental
9-- Portability : portable
11-- Functions for converting lazy 'Text' values to and from lazy
12-- 'ByteString', using several standard encodings.
14-- To make use of a much larger variety of encodings, use the @text-icu@
17module Data.Text.Lazy.Encoding
19 -- * Decoding ByteStrings to Text
28 -- * Encoding Text to ByteStrings
36import Data.ByteString.Lazy (ByteString)
37import Data.Text.Encoding.Error (OnDecodeError, strictDecode)
38import Data.Text.Lazy (Text)
39import qualified Data.Text.Lazy.Fusion as F
40import qualified Data.Text.Lazy.Encoding.Fusion as E
42-- | Decode a 'ByteString' containing UTF-8 encoded text.
43decodeUtf8With :: OnDecodeError -> ByteString -> Text
44decodeUtf8With onErr bs = F.unstream (E.streamUtf8 onErr bs)
45{-# INLINE decodeUtf8With #-}
47-- | Decode a 'ByteString' containing UTF-8 encoded text.
48decodeUtf8 :: ByteString -> Text
49decodeUtf8 = decodeUtf8With strictDecode
50{-# INLINE decodeUtf8 #-}
52-- | Encode text using UTF-8 encoding.
53encodeUtf8 :: Text -> ByteString
54encodeUtf8 txt = E.unstream (E.restreamUtf8 (F.stream txt))
55{-# INLINE encodeUtf8 #-}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list