POP3 messages: '=' always followed by '3D'?

Markus Schaber markus at schabi.de
Thu Sep 20 17:17:32 EDT 2001


Steve Canfield <stevecanfield at my-deja.com> schrub:

> I'm using poplib to retrieve email messages.  Whenever the text of the
> message contains an equals sign, it is always followed by '3D'.  Why
> is this?  To get the original text, do I have to do a
> search-and-replace operation on every line to convert '=3D' to '='?
> 
> For example, if the message contains this:
>   <abc def='ghi'>
> it will be retrieved as:
>   <abc def=3D'ghi'>
> 
> Am I missing something painfully obvious here?  Any suggestions for a
> easy and fast way to fix this?

This looks as the sender (or some converting mail server inbetween) 
used the Quoted Printable encoding. There, lots of characters 
(including the "=", and all characters with an byte value higher than 
127) are encoded by an = followed by the hex representation of the byte.

The messages usually have an Header saying:
Content-Transfer-Encoding: quoted-printable

I'd recommend you to read the appropriate RFCs, and perhaps the codecs 
in the Python standard library already have a Quoted Printable decoder.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list