stuart bishop muxphestuartbishopnet nando wrote ok get question number 2 question 2 flaw decode_header something thunderbird displays eduardo mônica decoded wrong character place ô reprdecode_headermsubject00 eduardo mxf4nica header tested subject iso88591qeduardo__mf4nica case right thing thunderbird display way intended answer use codecsdecode import codecs 20 encoding decode_headeriso88591qpf4nei 21 out21 pxf4nei 22 encoding out22 iso88591 23 print codecsdecodes encoding pônei well makes even harder use return value decode_header function instead encapsulating complexity email library forcing every user library find gets harder handling unicode domain names code convert email addresses ascii unicode representations found httpstuartbishopnetsoftwareemailaddress barry discuss getting code standard library think opened bug soon wrote 2004 bit learning curve suspect users library written similar helpers possibly several times eg nearly mandatory header decoder def decode_headers decode rfc2047 email header unicode string emailheaderdecode_headers b0decodeb1 ascii b return ujoins stuart bishop httpwwwstuartbishopnet wed 06 aug 2008 095450 0700 emailsig patch improve recognition attachment file name encodings