How do I decode unicode characters in the subject using email.message_from_string()?

Roy H. Han starsareblueandfaraway at gmail.com
Wed Feb 25 01:07:58 CET 2009


Dear python-list,

I'm having some trouble decoding an email header using the standard
imaplib.IMAP4 class and email.message_from_string method.

In particular, email.message_from_string() does not seem to properly
decode unicode characters in the subject.

How do I decode unicode characters in the subject?

I read on the documentation that the email module supports RFC 2047.
But is there a way to make imaplib.IMAP4 and email.message_from_string
use this protocol?  I'm using Python 2.5.2 on Fedora.  Perhaps this
problem has been fixed already in Python 2.6.

RHH



More information about the Python-list mailing list