You should know, that a ByteString
is really bad for things like iteration over it elements, but better for Concatation, etc.
If you want to work with ByteStrings, you have to convert the String to a ByteString, just do something like
import Data.ByteString.Lazy as B
and stick a B
in front of each function which works with them - most functions for String
also exists for ByteString
. Please notice - you have to convert the Strings you use to a ByteString with some functions.
If you use Data.ByteString.Lazy.Char8
instead, you can easily use pack
, but all chars greater than 255 will be truncated. Also, this type is more suitable for binary data and safes memory.
Edit: You should consider using the package text, if you want to work on text-strings. Look here for further details.