I am displaying new email with IMAP
, and everything looks fine, except for one message subject shows as:
=?utf-8?Q?Subject?=
How can I fix it?
In MIME terminology, those encoded chunks are called encoded-words. You can decode them like this:
import email.Header
text, encoding = email.Header.decode_header('=?utf-8?Q?Subject?=')[0]
Check out the docs for email.Header
for more details.