Unicode and Zipfile problems

Radovan Garabik garabik-news-2002-02 at kassiopeia.juls.savba.sk
Thu Nov 6 15:23:18 CET 2003

vincent wehren <vincent at visualtrans.de> wrote:
> "Gerson Kurz" <gerson.kurz at t-online.de> schrieb im Newsbeitrag
> news:3fa8d5ee.304218 at news.t-online.de...
> | AAAAAAAARG I hate the way python handles unicode. Here is a nice
> | problem for y'all to enjoy: say you have a variable thats unicode
> |
> | directory = u"c:\temp"
> |
> | Its unicode not because you want it to, but because its for example
> | read from _winreg which returns unicode.
> |
> | You do an os.listdir(directory). Note that all filenames returned are
> | now unicode. (Change introduced I believe in 2.3).
> Wrong.
> That's only true if type(directory) gives you <type 'unicode'>
> If you call str(directory) before doing os.listdir(directory)
> you (in most cases) want even notice and can continue doing what you want to
> do
> just fine - plus, and that's the good part - you can forget about
> those hacks you suggest later and which some would consider *evil*.
> It'll save yourself some time too.
> Hey, and leave my Swahili friends alone will ya! ;)

Uhm, AFAIK Swahili does not use any special characters in the alphabet 
(if you do not count digraphs, that is). Plain old ASCII is sufficient
Not that my remark is useful for anything, though.

> | Now, could anybody please just write a
> | "i-don't-care-if-my-app-can-display-klingon-characters" raw byte
> | encoding which doesn't throw any assertions and doesn't care whether
> | or not the characters are in the 0x7F range? Its ok if I cannot port
> | my batchscripts to swaheli, really.

but you HAVE TO care, since on MS Windows, if a filename is unicode,
it is UTF-16 and you just cannot convert it into stream of bytes
without messing up with encodings. UTF-16 is not even ASCII compatible,
after all.

| Radovan Garabík http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__    garabik @ kassiopeia.juls.savba.sk     |
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!

More information about the Python-list mailing list