New submission from sijian liang:
#!/usr/bin/python
#-*- coding:utf-8 -*-
import email
# from email.parser import Parser
def decode_email_header(header, sep=''):
l = []
for s, c in header:
if c:
l.append(s.decode(c))
else:
l.append(s)
return sep.join(l)
s = email.Header.decode_header('"=?gb18030?B?bWFpbGZvcnRlc3R0?="
<[email protected]>')
print decode_email_header(s)
s = email.Header.decode_header('=?gb18030?B?bWFpbGZvcnRlc3R0?=
<[email protected]>')
print decode_email_header(s)
# see output:
# "=?gb18030?B?bWFpbGZvcnRlc3R0?=" <[email protected]>
# mailfortestt<[email protected]>
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28122>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com