Decoding Internationalised Email Headers

August 10th, 2010
email, python
Every so often someone will email me something where the subject has unicode in it. My naive tools don't know what to do with it, and I see stuff like:
=?UTF-8?Q?[Sociological_Images]_New_Comment_On:_Satter=E2=80=99s_Hierarch?=  =?UTF-8?Q?y_of_Food_Needs?=
It turns out python has a module for this, providing email.header.decode_header. This gives me:
[Sociological_Images] New Comment On: Satter's Hierarchy of Food Needs
So much nicer.

I am continually happily surprised at the fraction of the time that what I want is already implemented in the python standard library.

Comment via: facebook

Recent posts on blogs I like:

Book Review: The Myth of Sex Addiction

I. David Ley’s The Myth of Sex Addiction is a stupid, wrong book saved only by the fact that the people it’s arguing with are stupider and wronger. II. “Sex addiction” is a proposed mental health condition, not recognized by the DSM or the ICD, where a pe…

via Thing of Things March 7, 2024

Your wedding doesn’t have to be that great

Your future happiness does not depend on how gorgeous this one day is. The post Your wedding doesn’t have to be that great appeared first on Otherwise.

via Otherwise March 4, 2024

When Nurses Lie to You

When the nurse comes to give you the flu shot, they say it won't hurt at all, right? And you trust them. Then they give you the shot, and it hurts! They lied to you. A lot of nurses lie to children about shots and blood draws. Part of it is they probabl…

via Lily Wise's Blog Posts February 28, 2024

more     (via openring)