Decoding 'funky' e-mail subjects

Jonas Galvez jg at
Tue Jun 8 14:38:22 CEST 2004

Paul Rubin wrote:
> A lot of those funny subjects come from spammers.  Never eval
> anything from anyone like that!!!

Hi Paul, yeah, actually, that kind of 'funky' subject is very common
on mailing-lists here in Brazil (where ISO-8859-1 is the standard). A
lot of people use crappy webmail software which spills out that kind
of mess. So I'm forced to deal with it :-)

By the way, this is for a mail2rss application which will enable easy
removal/blacklisting of spam, among other things.

Christos TZOTZIOY Georgiou wrote:
> A sound advice by Paul.  However, lots of those funny subjects come
> in legitimate e-mails from countries where the ascii range is not
> enough. So, a safer alternative to the code above is:
>     try: return string.atoi(str, 16)
>     except: return '?'
>     # int(s, base) was not available in 1.5.2

Thanks! Yeah, I tried using int(str, base) on Python 1.5.2, and I was
too lazy to look for the alternative when I was able to do that quick
and dirty eval() thingy :-)

\\ jonas galvez

More information about the Python-list mailing list