planet-mitchell-0.1.0: Planet Mitchell

Safe HaskellNone
LanguageHaskell2010

ByteString.Lazy.Utf8

Contents

Synopsis

Documentation

break :: (Char -> Bool) -> ByteString -> (ByteString, ByteString) #

Split a string into two parts: the first is the longest prefix that contains only characters that do not satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as '\0xFFFD' to the predicate.

drop :: Int64 -> ByteString -> ByteString #

drop n s returns the s without its first n characters. If s has less than n characters, then we return an empty string.

foldl :: (a -> Char -> a) -> a -> ByteString -> a #

Traverse a bytestring (left biased). This function is strict in the accumulator.

foldr :: (Char -> a -> a) -> a -> ByteString -> a #

Traverse a bytestring (right biased).

fromString :: String -> ByteString #

Converts a Haskell string into a UTF8 encoded bytestring.

length :: ByteString -> Int #

Counts the number of characters encoded in the bytestring. Note that this includes replacement characters.

span :: (Char -> Bool) -> ByteString -> (ByteString, ByteString) #

Split a string into two parts: the first is the longest prefix that contains only characters that satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as '\0xFFFD' to the predicate.

splitAt :: Int64 -> ByteString -> (ByteString, ByteString) #

Split after a given number of characters. Negative values are treated as if they are 0.

take :: Int64 -> ByteString -> ByteString #

take n s returns the first n characters of s. If s has less than n characters, then we return the whole of s.

toString :: ByteString -> String #

Convert a UTF8 encoded bytestring into a Haskell string. Invalid characters are replaced with '\xFFFD'.

uncons :: ByteString -> Maybe (Char, ByteString) #

Get the first character of a byte string, if any. Malformed characters are replaced by '\0xFFFD'.

Optics

utf8 :: Prism' ByteString Text #

Encode/Decode a lazy Text to/from lazy ByteString, via UTF-8.

Note: This function does not decode lazily, as it must consume the entire input before deciding whether or not it fails.

>>> ByteString.unpack (utf8 # "☃")
[226,152,131]