module HsLua.Core.Utf8
( toString
, toText
, fromString
, fromText
) where
import Data.ByteString (ByteString)
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Encoding as TextEncoding
import qualified Data.Text.Encoding.Error as TextEncoding
toString :: ByteString -> String
toString :: ByteString -> String
toString = Text -> String
T.unpack (Text -> String) -> (ByteString -> Text) -> ByteString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
toText
{-# INLINABLE toString #-}
toText :: ByteString -> Text
toText :: ByteString -> Text
toText = OnDecodeError -> ByteString -> Text
TextEncoding.decodeUtf8With OnDecodeError
TextEncoding.lenientDecode
{-# INLINABLE toText #-}
fromString :: String -> ByteString
fromString :: String -> ByteString
fromString = Text -> ByteString
TextEncoding.encodeUtf8 (Text -> ByteString) -> (String -> Text) -> String -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
{-# INLINABLE fromString #-}
fromText :: Text -> ByteString
fromText :: Text -> ByteString
fromText = Text -> ByteString
TextEncoding.encodeUtf8
{-# INLINABLE fromText #-}