pack package:bytestring

O(n) Convert a [Word8] into a ByteString. For applications with large numbers of string literals, pack can be a bottleneck. In such cases, consider using unsafePackAddress (GHC only).
O(n) Convert a String into a ByteString For applications with large numbers of string literals, pack can be a bottleneck.
O(n) Convert a '[Word8]' into a ByteString.
O(n) Convert a String into a ByteString.
O(n). Convert a list into a ShortByteString
O(n). Construct a new ByteString from a CString. The resulting ByteString is an immutable copy of the original CString, and is managed on the Haskell heap. The original CString must be null terminated.
O(n). Construct a new ByteString from a CStringLen. The resulting ByteString is an immutable copy of the original CStringLen. The ByteString is a normal Haskell value and will be managed on the Haskell heap.
A specialised version of zipWith for the common case of a simultaneous map over two ByteStrings, to build a 3rd.
A specialised version of zipWith for the common case of a simultaneous map over two ByteStrings, to build a 3rd.
O(n). Construct a new ShortByteString from a CString. The resulting ShortByteString is an immutable copy of the original CString, and is managed on the Haskell heap. The original CString must be null terminated.
O(n). Construct a new ShortByteString from a CStringLen. The resulting ShortByteString is an immutable copy of the original CStringLen. The ShortByteString is a normal Haskell value and will be managed on the Haskell heap.
O(n) Converts a ByteString to a [Word8].
O(n) Converts a ByteString to a String.
O(n) Pack a null-terminated sequence of bytes, pointed to by an Addr# (an arbitrary machine address assumed to point outside the garbage-collected heap) into a ByteString. A much faster way to create an Addr# is with an unboxed string literal, than to pack a boxed string. A unboxed string literal is compiled to a static char [] by GHC. Establishing the length of the string requires a call to strlen(3), so the Addr# must point to a null-terminated buffer (as is the case with "string"# literals in GHC). Use unsafePackAddressLen if you know the length of the string statically. An example:
literalFS = unsafePackAddress "literal"#
This function is unsafe. If you modify the buffer pointed to by the original Addr# this modification will be reflected in the resulting ByteString, breaking referential transparency. Note this also won't work if your Addr# has embedded '\0' characters in the string, as strlen will return too short a length.
See unsafePackAddress. This function is similar, but takes an additional length argument rather then computing it with strlen. Therefore embedding '\0' characters is possible.