@@ -85,12 +85,14 @@ import qualified Streamly.Prelude as S
86-- | Decode a stream of bytes to Unicode characters by mapping each byte to a
86-- | Decode a stream of bytes to Unicode characters by mapping each byte to a
87-- corresponding Unicode 'Char' in 0-255 range.
87-- corresponding Unicode 'Char' in 0-255 range.
88+{-# INLINE decodeChar8 #-}
88decodeChar8 :: (IsStream t, Monad m) => t m Word8 -> t m Char
89decodeChar8 :: (IsStream t, Monad m) => t m Word8 -> t m Char
89decodeChar8 = S.map (unsafeChr . fromIntegral)
90decodeChar8 = S.map (unsafeChr . fromIntegral)
91-- | Encode a stream of Unicode characters to bytes by mapping each character
92-- | Encode a stream of Unicode characters to bytes by mapping each character
92-- to a byte in 0-255 range. Throws an error if the input stream contains
93-- to a byte in 0-255 range. Throws an error if the input stream contains
93-- characters beyond 255.
94-- characters beyond 255.
95+{-# INLINE encodeChar8 #-}
94encodeChar8 :: (IsStream t, Monad m) => t m Char -> t m Word8
96encodeChar8 :: (IsStream t, Monad m) => t m Char -> t m Word8
95encodeChar8 = S.map convert
97encodeChar8 = S.map convert
@@ -104,6 +106,7 @@ encodeChar8 = S.map convert
104-- | Like 'encodeChar8' but silently truncates and maps input characters beyond
106-- | Like 'encodeChar8' but silently truncates and maps input characters beyond
105-- 255 to (incorrect) chars in 0-255 range. No error or exception is thrown
107-- 255 to (incorrect) chars in 0-255 range. No error or exception is thrown
106-- when such truncation occurs.
108-- when such truncation occurs.
109+{-# INLINE encodeChar8Unchecked #-}
107encodeChar8Unchecked :: (IsStream t, Monad m) => t m Char -> t m Word8
110encodeChar8Unchecked :: (IsStream t, Monad m) => t m Char -> t m Word8
108encodeChar8Unchecked = S.map (fromIntegral . ord)
111encodeChar8Unchecked = S.map (fromIntegral . ord)