Internationalized To:'s and Cc:'s

Nobody nobody at nowhere.com
Wed Oct 7 07:33:55 CEST 2009


On Tue, 06 Oct 2009 06:33:37 -0700, Maxim Kuleshov wrote:

> How should I correctly construct internationalized base64'ed MIME
> header?
> The problem is that 'real name' _should_ be encoded, but the email
> address - should not.
> For example, ?utf-8?bla-bla=?= <email at domain> should be the correct
> format, and
> ?utf-8?bla-bla-bla-bla=?= - incorrect.

   from email.header import Header, decode_header
   h = Header()
   h.append("Real Name", 'utf-8')
   h.append(" <email at domain>")
   h.encode()
 '=?utf-8?q?Real_Name?=  <email at domain>'
   decode_header(_)
 [('Real Name', 'utf-8'), ('<email at domain>', None)]




More information about the Python-list mailing list