{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module Data.Text.Encoding.Sized
(
decodeLatin1,
decodeUtf8,
decodeUtf16LE,
decodeUtf16BE,
decodeUtf32LE,
decodeUtf32BE,
decodeUtf8',
decodeUtf8With,
decodeUtf16LEWith,
decodeUtf16BEWith,
decodeUtf32LEWith,
decodeUtf32BEWith,
streamDecodeUtf8,
streamDecodeUtf8With,
E.Decoding (..),
encodeUtf8,
encodeUtf16LE,
encodeUtf16BE,
encodeUtf32LE,
encodeUtf32BE,
encodeUtf8Builder,
encodeUtf8BuilderEscaped,
)
where
import Data.ByteString (ByteString)
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Builder.Prim as BP
import Data.Sized
import qualified Data.Text.Encoding as E
import Data.Text.Encoding.Error (OnDecodeError, UnicodeException)
import Data.Text.Sized
import Data.Word (Word8)
import GHC.Stack
decodeLatin1 :: HasCallStack => Sized s ByteString -> SizedStrictText s
decodeLatin1 :: Sized s ByteString -> SizedStrictText s
decodeLatin1 = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Text
E.decodeLatin1
{-# INLINE decodeLatin1 #-}
decodeUtf8With :: HasCallStack => OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf8With :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf8With OnDecodeError
onError = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((ByteString -> Text) -> Sized s ByteString -> SizedStrictText s)
-> (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b. (a -> b) -> a -> b
$ OnDecodeError -> ByteString -> Text
E.decodeUtf8With OnDecodeError
onError
{-# INLINE decodeUtf8With #-}
streamDecodeUtf8 :: HasCallStack => Sized s ByteString -> Sized s E.Decoding
streamDecodeUtf8 :: Sized s ByteString -> Sized s Decoding
streamDecodeUtf8 = (ByteString -> Decoding) -> Sized s ByteString -> Sized s Decoding
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Decoding
E.streamDecodeUtf8
{-# INLINE streamDecodeUtf8 #-}
streamDecodeUtf8With :: HasCallStack => OnDecodeError -> Sized s ByteString -> Sized s E.Decoding
streamDecodeUtf8With :: OnDecodeError -> Sized s ByteString -> Sized s Decoding
streamDecodeUtf8With OnDecodeError
onError = (ByteString -> Decoding) -> Sized s ByteString -> Sized s Decoding
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((ByteString -> Decoding)
-> Sized s ByteString -> Sized s Decoding)
-> (ByteString -> Decoding)
-> Sized s ByteString
-> Sized s Decoding
forall a b. (a -> b) -> a -> b
$ OnDecodeError -> ByteString -> Decoding
E.streamDecodeUtf8With OnDecodeError
onError
{-# INLINE streamDecodeUtf8With #-}
decodeUtf8 :: Sized s ByteString -> SizedStrictText s
decodeUtf8 :: Sized s ByteString -> SizedStrictText s
decodeUtf8 = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Text
E.decodeUtf8
{-# INLINE decodeUtf8 #-}
decodeUtf8' :: HasCallStack => Sized s ByteString -> Either UnicodeException (SizedStrictText s)
decodeUtf8' :: Sized s ByteString -> Either UnicodeException (SizedStrictText s)
decodeUtf8' = (Text -> SizedStrictText s)
-> Either UnicodeException Text
-> Either UnicodeException (SizedStrictText s)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> SizedStrictText s
forall a s. a -> Sized s a
trustedSized (Either UnicodeException Text
-> Either UnicodeException (SizedStrictText s))
-> (Sized s ByteString -> Either UnicodeException Text)
-> Sized s ByteString
-> Either UnicodeException (SizedStrictText s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either UnicodeException Text
E.decodeUtf8' (ByteString -> Either UnicodeException Text)
-> (Sized s ByteString -> ByteString)
-> Sized s ByteString
-> Either UnicodeException Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sized s ByteString -> ByteString
forall s a. Sized s a -> a
getSized
{-# INLINE decodeUtf8' #-}
encodeUtf8Builder :: SizedStrictText s -> Sized s B.Builder
encodeUtf8Builder :: SizedStrictText s -> Sized s Builder
encodeUtf8Builder = (Text -> Builder) -> SizedStrictText s -> Sized s Builder
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized Text -> Builder
E.encodeUtf8Builder
{-# INLINE encodeUtf8Builder #-}
encodeUtf8BuilderEscaped :: BP.BoundedPrim Word8 -> SizedStrictText s -> Sized s B.Builder
encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> SizedStrictText s -> Sized s Builder
encodeUtf8BuilderEscaped BoundedPrim Word8
be = (Text -> Builder) -> SizedStrictText s -> Sized s Builder
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((Text -> Builder) -> SizedStrictText s -> Sized s Builder)
-> (Text -> Builder) -> SizedStrictText s -> Sized s Builder
forall a b. (a -> b) -> a -> b
$ BoundedPrim Word8 -> Text -> Builder
E.encodeUtf8BuilderEscaped BoundedPrim Word8
be
{-# INLINE encodeUtf8BuilderEscaped #-}
encodeUtf8 :: SizedStrictText s -> Sized s ByteString
encodeUtf8 :: SizedStrictText s -> Sized s ByteString
encodeUtf8 = (Text -> ByteString) -> SizedStrictText s -> Sized s ByteString
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized Text -> ByteString
E.encodeUtf8
{-# INLINE encodeUtf8 #-}
decodeUtf16LEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf16LEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf16LEWith OnDecodeError
onError = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((ByteString -> Text) -> Sized s ByteString -> SizedStrictText s)
-> (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b. (a -> b) -> a -> b
$ OnDecodeError -> ByteString -> Text
E.decodeUtf16LEWith OnDecodeError
onError
{-# INLINE decodeUtf16LEWith #-}
decodeUtf16LE :: Sized s ByteString -> SizedStrictText s
decodeUtf16LE :: Sized s ByteString -> SizedStrictText s
decodeUtf16LE = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Text
E.decodeUtf16LE
{-# INLINE decodeUtf16LE #-}
decodeUtf16BEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf16BEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf16BEWith OnDecodeError
onError = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((ByteString -> Text) -> Sized s ByteString -> SizedStrictText s)
-> (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b. (a -> b) -> a -> b
$ OnDecodeError -> ByteString -> Text
E.decodeUtf16BEWith OnDecodeError
onError
{-# INLINE decodeUtf16BEWith #-}
decodeUtf16BE :: Sized s ByteString -> SizedStrictText s
decodeUtf16BE :: Sized s ByteString -> SizedStrictText s
decodeUtf16BE = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Text
E.decodeUtf16BE
{-# INLINE decodeUtf16BE #-}
encodeUtf16LE :: SizedStrictText s -> Sized s ByteString
encodeUtf16LE :: SizedStrictText s -> Sized s ByteString
encodeUtf16LE = (Text -> ByteString) -> SizedStrictText s -> Sized s ByteString
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized Text -> ByteString
E.encodeUtf16LE
{-# INLINE encodeUtf16LE #-}
encodeUtf16BE :: SizedStrictText s -> Sized s ByteString
encodeUtf16BE :: SizedStrictText s -> Sized s ByteString
encodeUtf16BE = (Text -> ByteString) -> SizedStrictText s -> Sized s ByteString
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized Text -> ByteString
E.encodeUtf16BE
{-# INLINE encodeUtf16BE #-}
decodeUtf32LEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf32LEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf32LEWith OnDecodeError
onError = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((ByteString -> Text) -> Sized s ByteString -> SizedStrictText s)
-> (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b. (a -> b) -> a -> b
$ OnDecodeError -> ByteString -> Text
E.decodeUtf32LEWith OnDecodeError
onError
{-# INLINE decodeUtf32LEWith #-}
decodeUtf32LE :: Sized s ByteString -> SizedStrictText s
decodeUtf32LE :: Sized s ByteString -> SizedStrictText s
decodeUtf32LE = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Text
E.decodeUtf32LE
{-# INLINE decodeUtf32LE #-}
decodeUtf32BEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf32BEWith :: OnDecodeError -> Sized s ByteString -> SizedStrictText s
decodeUtf32BEWith OnDecodeError
onError = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ((ByteString -> Text) -> Sized s ByteString -> SizedStrictText s)
-> (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b. (a -> b) -> a -> b
$ OnDecodeError -> ByteString -> Text
E.decodeUtf32BEWith OnDecodeError
onError
{-# INLINE decodeUtf32BEWith #-}
decodeUtf32BE :: Sized s ByteString -> SizedStrictText s
decodeUtf32BE :: Sized s ByteString -> SizedStrictText s
decodeUtf32BE = (ByteString -> Text) -> Sized s ByteString -> SizedStrictText s
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized ByteString -> Text
E.decodeUtf32BE
{-# INLINE decodeUtf32BE #-}
encodeUtf32LE :: SizedStrictText s -> Sized s ByteString
encodeUtf32LE :: SizedStrictText s -> Sized s ByteString
encodeUtf32LE = (Text -> ByteString) -> SizedStrictText s -> Sized s ByteString
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized Text -> ByteString
E.encodeUtf32LE
{-# INLINE encodeUtf32LE #-}
encodeUtf32BE :: SizedStrictText s -> Sized s ByteString
encodeUtf32BE :: SizedStrictText s -> Sized s ByteString
encodeUtf32BE = (Text -> ByteString) -> SizedStrictText s -> Sized s ByteString
forall a b s. (a -> b) -> Sized s a -> Sized s b
overSized Text -> ByteString
E.encodeUtf32BE
{-# INLINE encodeUtf32BE #-}