So I want to access the individual bytes of the UTF-8 encoding of a string.
I tried using Data.ByteString.Char8.pack
, but that seems to just truncate it to the last byte of each character:
ghci> Char8.pack "\945\946\947"
"\177\178\179"
This isn't a problem if I can read the string from a file:
ghci> Prelude.writeFile "temp.txt" "\945\946\947" >> Char8.readFile "temp.txt"
"\206\177\206\178\206\179"
But I'd like a pure way to convert String -> ByteString
without truncation, and hoogle isn't very helpful.