Haskell unicode character and byte string conversions

‹ Breaked | "Your profile could not be opened correctly" in Linux Chrome ›

  • Convert Char to [Word8] (using UTF-8):
    • Using utf-string: (encode . (: [])) :: Char -> [Word8]
    • Using Text and ByteString: (Data.ByteString.unpack . encodeUtf8 . Data.Text.singleton) :: Char -> [Word8]
  • Convert String to ByteString (using UTF-8):
    • Using utf-string: fromString :: String -> ByteString
    • Using Text: (encodeUtf8 . Data.Text.pack) :: String -> ByteString
Subscribe to All Posts - Wesley Tanaka