unicode encoding usablilty problem

"Martin v. Löwis" martin at v.loewis.de
Sun Feb 20 04:50:30 EST 2005


Thomas Heller wrote:
> Is it possible to specify a byte string literal when running with the -U option?

Not literally. However, you can specify things like

bytes = [0x47, 0x49, 0x4f, 0x50, 0x01, 0x00]
bytes = ''.join((chr(x) for x in bytes))

Alternatively, you could rely on the 1:1 feature of Latin-1:

bytes = "GIOP\x01\0".encode("l1")

Regards,
Martin



More information about the Python-list mailing list