[Baypiggies] charsets in email headers

Brent Tubbs brent.tubbs at gmail.com
Mon Aug 25 23:52:28 CEST 2008

Thank you for the link, Jason.   I'd been staring at that page (as
well as http://docs.python.org/lib/module-email.charset.html) for a
while before emailing the group, but it's over my head and there is no
example for converting from one charset to another.  An example from
someone who's done it would be most welcome.

Thanks again,

On Mon, Aug 25, 2008 at 2:20 PM, Jason Culverhouse
<jason at mischievous.org> wrote:
> Right here...
> http://docs.python.org/lib/module-email.header.html
> from email.header import decode_header
> decode_header('=?windows-1252?Q?=5BInvitation=5D_dummy_event_4_=40_Tue_Aug_26_10pm_=96_11=3A?=')
> [('[Invitation] dummy event 4 @ Tue Aug 26 10pm \x96 11:', 'windows-1252')]
> Jason
> On Aug 25, 2008, at 1:46 PM, Brent Tubbs wrote:
>> I'm writing a Google App Engine app that accepts incoming emails using
>> the free smtp2web.com service.  Things are generally working, but some
>> (not all) subject lines in the emails look like this (this one's a
>> Google Calendar event invitation):
>> =?windows-1252?Q?=5BInvitation=5D_dummy_event_4_=40_Tue_Aug_26_10pm_=96_11=3A?=
>>       =?windows-1252?Q?30pm_=28=22Schmobag=5FHogfather=22=29?=
>> I've learned that that's got something to do with the subject being in
>> the windows-1252 charset, but I'm mystified as to how to turn that
>> into human-readable ASCII.  The python email module has a charset
>> class that's supposed to help with this I think, but I don't know how
>> to make it do what I need.
>> Any suggestions on the best way to turn the ugly string above into
>> something nicer?
>> Thanks,
>> Brent
>> _______________________________________________
>> Baypiggies mailing list
>> Baypiggies at python.org
>> To change your subscription options or unsubscribe:
>> http://mail.python.org/mailman/listinfo/baypiggies

More information about the Baypiggies mailing list