Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'encoded': 0.07; 'utf-8': 0.07; '[1]:': 0.09; '[2]:': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '8-bit': 0.16; '[2].': 0.16; 'charset,': 0.16; 'cleaner': 0.16; 'fallback': 0.16; 'filename:fname piece:signature': 0.16; 'gnupg': 0.16; 'how,': 0.16; 'received:76.96': 0.16; 'received:mail.comcast.net': 0.16; 'url:general': 0.16; 'url:gmane': 0.16; 'url:thread': 0.16; 'subject:python': 0.16; 'url:org)': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'module,': 0.24; 'received:comcast.net': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'signed': 0.27; 'header:In-Reply-To:1': 0.27; 'asked': 0.31; 'url:wiki': 0.31; '-0700,': 0.31; 'url:wikipedia': 0.31; 'figure': 0.32; 'url:python': 0.33; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'received:76': 0.38; 'information,': 0.61; 'back': 0.62; 'content- disposition:inline': 0.62; 'email addr:yahoo.com': 0.64; 'more': 0.64; 'here': 0.66; 'response.': 0.68; 'jul': 0.74; 'to:addr:yahoo.com': 0.81; ':).': 0.84; 'trevor': 0.84; 'url:master': 0.84; '8bit': 0.91; 'encrypted': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin; t=1375078573; bh=AFjbhItJcsd9aiv9zBHkQYMBZKm9WReLLp4AR8Pz90E=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=AYNX/+deWAdczs+D5CvT+mpWHr7nwKZgXeJ0xolnwi53XuIlnUnICvThGhyUFCOYn H6/6CDRyct3oKLyqxm/ElcURlHIySVyFyy7ue3w0lKXdJXGagPq9AE0ilDrXwwlEKL OvgfQ4oPAy/XBJaYJ8lFA1uSYSLoSqlhPWFDG3oc= Date: Sun, 28 Jul 2013 23:16:12 -0700 From: "W. Trevor King" To: rurpy@yahoo.com Subject: Re: [python] email 8bit encoding References: <36aa5535-a821-4d7e-8414-1e40820705e4@googlegroups.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="k1lZvvs/B4yU6o8G" Content-Disposition: inline In-Reply-To: <36aa5535-a821-4d7e-8414-1e40820705e4@googlegroups.com> OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8; url=http://tremily.us/pubkey.txt User-Agent: Mutt/1.5.21 (2010-09-15) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1375124639; bh=Zxr86oK6LtW7FmWhumV2VDMVlzD0m/tUywcB0MsZ9Yg=; h=Received:Received:Received:Date:From:To:Subject:Message-ID: MIME-Version:Content-Type; b=U2UocdCioiHMvOjTTVIyEHq4qIbQAvvNvipCeQFlK4AslsbQQBydx+IMUGH1sskF2 kM9eINAwtK/7porF0k4Os+xW5LZcvlUgyGGm5raAhtFRmnxMthGBpfnYOCmrf4nYXa dLtlYi3/nwlXeCN3hQa+lGg5dE8oFBGn7TaInF3JQjJ8dQsFmP89xDeZpr+MNKUfdY V/qDI63K4as79pN2vCY4xRWxVKyROEyJVI92WqvScLE8r4DAbtEKoKtXw9GwZBmITB fcgeFj3zrC3V900uzqFiDx3dDfHNZwVBrBa6Cn0sEHq7CTJizQ+EzhraflSU/VbThO 1tE65xo2Q/9yA== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375124803 news.xs4all.nl 15923 [2001:888:2000:d::a6]:33671 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51474 --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 28, 2013 at 04:41:27PM -0700, rurpy@yahoo.com wrote: > How, using Python-3.3's email module, do I "flatten" (I think > that's the right term) a Message object to get utf-8 encoded > body with the headers: > Content-Type: text/plain; charset=3DUTF-8 > Content-Transfer-Encoding: 8bit > when the message payload was set to a python (unicode) string? I asked about this a while back [1], but never got a response. My current best-guess is here [2]. My fallback flattening works for everything except the 8-bit encoded messages using the UTF-16 charset, but it's pretty ugly. Let me know if you figure out something cleaner :). Cheers, Trevor [1]: http://thread.gmane.org/gmane.comp.python.general/725425 [2]: https://github.com/wking/rss2email/blob/master/rss2email/email.py#L226 --=20 This email may be signed or encrypted with GnuPG (http://www.gnupg.org). For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy --k1lZvvs/B4yU6o8G Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQIcBAEBAgAGBQJR9giiAAoJEKKfehoaNkbto/AP/2lN0kcKTO9FHwRs5bKlhxLs 4KZ03VRDAOocVnL7mRwAIhvcA0WVRl6PJRb83zqS8UKAacGxcsUNXaZHXAbzaGrB 3RPrpVKtwwycLHpCsEoQiTVDSglNiXypbjgzorXlv9Mb/ZlqN8nvMavntbJ7IVSA 2elOiQcQeEq6ofQQbJkf6RVzbJA+bUbAomthbK5QoLi/CKiaLy0AEc78ZFFmVUAZ mLHmxW7Z3PsQrXCDX56TrHulUfbmPMmbpmrEb1JW1dJgnNry8lL5xjUUj8cZemS6 oLL+EIWLkPiNEknonas3qVpj5yylJYuyF318ZY5iPdKLy7J5DW4Id6ILuyFxQej9 u2LAbpSZcbup88CVq/zM4AikvFb4ibF0MOwbMXdZVAwFGnGr6wKLe3rQZOBepbVG 3gHekfhTe+7fnea/qdl91wpm4L92UJHoinLFX8A9cQOmz3LjxzF+XZXS5PN2qdiT SyewiNizeC91VvH23SIpC4ezxqlX+LtoTh1n821di3+2EperYDBL6wfzpXe3DA8a nPK5cX1j9AIOEMHs9o+PBPPTChPfTDa6oxcE567nLW0n1uYj83qvazXXuvZB/YbZ +i+Z0Ex0/IB7ZWOETqmhFXAykV0M6to4SqN4yMtkcxRebihkz6FOFFAxgx4+W3EM c+XK+FKJfolhRHl7Yagh =1XE8 -----END PGP SIGNATURE----- --k1lZvvs/B4yU6o8G--