email package vs. mimify.mime_encode_header

Ilpo Nyyssönen iny+news at iki.fi
Mon Oct 20 01:21:35 EDT 2003


Barry Warsaw <barry at python.org> writes:

> 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.

But I do not know it. 

The point really is that the encoding should be done in such way that
only the minimum amount is encoded. Now it always encodes the whole
given text. And mimify does it like I want. (But it doesn't handle
other charsets, so is not that way enough.)

> 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.

Yes, I need to know the charset, but the Header should not encode the
whole string. It should encode just the parts that need it.

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('foo bär baz')
'foo =?ISO-8859-1?Q?b=E4r?= baz'
>>> from email.Header import Header
>>> Header('foo bär baz', 'iso-8859-1').encode()
'=?iso-8859-1?q?foo_b=E4r_baz?='

-- 
Ilpo Nyyssönen # biny # /* :-) */




More information about the Python-list mailing list