Reading/Writing Binary Data in Haskell

Martin Sjögren martin@strakt.com
10 Jul 2003 09:28:38 +0200


--=-rvfqrx4U/ESSBpVmJU4n
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

tor 2003-07-10 klockan 04.56 skrev Glynn Clements:
> OTOH, existing implementations (at least GHC and Hugs) currently read
> and write "8-bit binary", i.e. characters 0-255 get read and written
> "as-is" and anything else breaks, and changing that would probably
> break a fair amount of existing code.

What I would like to see, is a package for converting between different
encodings and character sets. Python has two types for strings, 'str'
(which is just a sequence of octets) and 'unicode'. You can encode and
decode between them, I find this pretty neat:
  'foo =E5=E4=F6'.decode('latin1') -> unicode string
  ustr.encode('latin1') -> string, breaks if there are non-latin1
characters in the string
  ustr.encode('utf-8') -> UTF-8 representation of the string.

If I recall correctly, the 'str' type is being replaced with another
type to highlight that it's actually only a sequence of bytes, whereas
'unicode' are Really Nice strings...

Having something like this in Haskell would be wonderful, unfortunately
I don't know much about Unicode beyond happily using it, so I don't have
any suggestions or anything. :)


/Martin
--=20
Martin Sj=F6gren
  martin@strakt.com
  Phone: +46 (0)31 7490880       Cell: +46 (0)739 169191
  GPG key: http://www.strakt.com/~martin/gpg.html

--=-rvfqrx4U/ESSBpVmJU4n
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQA/DRWlGpBPiZwE9FYRAqSUAJ9xJnF9LpCBXC6QlbSqC5PhKFuihQCfZd18
SdnP/QTsDgTeN5em9ODJM0g=
=Qgi9
-----END PGP SIGNATURE-----

--=-rvfqrx4U/ESSBpVmJU4n--