module Data.ByteString.Encoding
(
encode
, decode
, TextEncoding
, latin1
, utf8
, utf8_bom
, utf16
, utf16le
, utf16be
, utf32
, utf32le
, utf32be
, localeEncoding
, char8
, mkTextEncoding
) where
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Lazy.Encoding as L
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import System.IO
encode :: TextEncoding -> T.Text -> B.ByteString
encode :: TextEncoding -> Text -> ByteString
encode TextEncoding
enc = ByteString -> ByteString
BL.toStrict (ByteString -> ByteString)
-> (Text -> ByteString) -> Text -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> Text -> ByteString
L.encode TextEncoding
enc (Text -> ByteString) -> (Text -> Text) -> Text -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
TL.fromStrict
decode :: TextEncoding -> B.ByteString -> T.Text
decode :: TextEncoding -> ByteString -> Text
decode TextEncoding
enc = Text -> Text
TL.toStrict (Text -> Text) -> (ByteString -> Text) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextEncoding -> ByteString -> Text
L.decode TextEncoding
enc (ByteString -> Text)
-> (ByteString -> ByteString) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BL.fromStrict