email package vs. mimify.mime_encode_header

Barry Warsaw barry at python.org
Sun Oct 19 12:24:10 EDT 2003


On Sun, 2003-10-19 at 05:06, Ilpo Nyyssönen wrote:
> Tim Roberts <timr at probo.com> writes:
> 
> >>From my point of view this looks like dropping an important feature. I
> >>really do not want to encode an ascii only header, but if the encoding
> >>is needed, it needs to be there. With mimify this is handled
> >>automatically, with Header I would need to do that by hand.
> >
> > You OUGHT to be doing it by hand in both cases.  You'll need to parse the
> > name anyway to get the addresses for SMTP.
> 
> OK, that might be true, but lets look the actually encoded parts:
> 
> Python 2.3.2 (#1, Oct 11 2003, 11:13:40) 
> [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import mimify
> >>> mimify.mime_encode_header('This is an ascii only header')
> 'This is an ascii only header'
> >>> from email.Header import Header
> >>> Header('This is an ascii only header', 'iso-8859-1').encode()
> '=?iso-8859-1?q?This_is_an_ascii_only_header?='
> 
> Encoding that is unnecessary. It is harder to read that as raw without
> decoding.
> 
> It will cause problems in programs that do something automatically,
> but do not decode it. A good example is filtering that is done based
> on subject prefixes.
> 
> >From my point of view the encoding done by the Header is unusable.

I'm only seeing the tail end of this discussion, but you're not really
comparing apples to apples here.  If you know the string going into your
header is ASCII, and you don't want it RFC 2047 encoded, then don't
provide a charset argument (or use the default == 'us-ascii').  I.e.

>>> from email.Header import Header
>>> Header('This is an ascii only header').encode()
'This is an ascii only header'

mimify.mime_encode_header() really only helps you when the header is
Latin-1, otherwise you still need to know what charset you want to
encode the header to.  Besides, mimify's CHARSET is a module global, so
that really sucks.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 316 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20031019/f7f28e0b/attachment.sig>


More information about the Python-list mailing list