HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleutf8-string-1.0.2Haskell2010

Data.ByteString.UTF8

This module provides fast, validated encoding and decoding functions between ByteStrings and Strings. It does not exactly match the output of the Codec.Binary.UTF8.String output for invalid encodings as the number of replacement characters is sometimes longer.

  • 1 type
  • 16 values
datadata ByteString
#

A space-efficient representation of a Word8 vector, supporting many efficient operations.

A ByteString contains 8-bit bytes, or by using the operations from Data.ByteString.Char8 it can be interpreted as containing 8-bit characters.

Instances13IsList, Eq, Data, Ord, Read, Show, …
  • IsList ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Eq ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Data ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Ord ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Show ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • Semigroup ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Monoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • NFData ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Lift ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • UTF8Bytes ByteString IntDefined in utf8-string-1.0.2 · Codec.Binary.UTF8.Generic
  • type Item ByteString = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
valuedecode :: ByteString -> Maybe (Char, Int)
#

Try to extract a character from a byte string. Returns Nothing if there are no more bytes in the byte string. Otherwise, it returns a decoded character and the number of bytes used in its representation. Errors are replaced by character '\0xFFFD'.

valuetake :: Int -> 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.

valuedrop :: Int -> 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.

valuespan :: (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.

valuebreak :: (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.

valuetoString :: ByteString -> String
#

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

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

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

valuelength :: ByteString -> Int
#

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

valuelines :: ByteString -> [ByteString]
#

Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. See also lines'.

valuelines' :: ByteString -> [ByteString]
#

Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. This function preserves the terminators. See also lines.