email and unicode

janwillem jwevandijk at
Sun Apr 18 06:02:23 EDT 2010

I have a script that extracts attachments from all emails in a mbox
(largely based on;
thanks ActiveState). It works fine until it encounters an attachment
with a unicode file name (Ukrainian in my case). I cannot get working
the line
which is line 39 in the activestate snippet.

How can you get the unicode file name into the replace string of line
35 of the snippet:
replace = ReplaceString % dict(content_type=ct,
without getting this nasty error message about ascii encoding?

More information about the Python-list mailing list