diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-12-14 00:29:27 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-12-14 00:29:27 (GMT) |
commit | a9aa34c7cd3eb9bfc88d2a4eed0ad78a8e8c885a (patch) | |
tree | f2b39b0ec1c97707601eb1253ebffc4cd2357761 /Doc | |
parent | 910c52fcf4ef25ce4c765aa3f2733704b4adaab7 (diff) | |
download | cpython-a9aa34c7cd3eb9bfc88d2a4eed0ad78a8e8c885a.zip cpython-a9aa34c7cd3eb9bfc88d2a4eed0ad78a8e8c885a.tar.gz cpython-a9aa34c7cd3eb9bfc88d2a4eed0ad78a8e8c885a.tar.bz2 |
#1078919: document requirement to use triples for non-ascii add_header parms.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/email.message.rst | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Doc/library/email.message.rst b/Doc/library/email.message.rst index fa1df88..6f40c05 100644 --- a/Doc/library/email.message.rst +++ b/Doc/library/email.message.rst @@ -266,7 +266,12 @@ Here are the methods of the :class:`Message` class: taken as the parameter name, with underscores converted to dashes (since dashes are illegal in Python identifiers). Normally, the parameter will be added as ``key="value"`` unless the value is ``None``, in which case - only the key will be added. + only the key will be added. If the value contains non-ASCII characters, + it must be specified as a three tuple in the format + ``(CHARSET, LANGUAGE, VALUE)``, where ``CHARSET`` is a string naming the + charset to be used to encode the value, ``LANGUAGE`` can usually be set + to ``None`` or the empty string (see :RFC:`2231` for other possibilities), + and ``VALUE`` is the string value containing non-ASCII code points. Here's an example:: @@ -276,6 +281,15 @@ Here are the methods of the :class:`Message` class: Content-Disposition: attachment; filename="bud.gif" + An example with with non-ASCII characters:: + + msg.add_header('Content-Disposition', 'attachment', + filename=('iso-8859-1', '', 'Fußballer.ppt')) + + Which produces :: + + Content-Disposition: attachment; filename*="iso-8859-1''Fu%DFballer.ppt" + .. method:: replace_header(_name, _value) @@ -380,7 +394,7 @@ Here are the methods of the :class:`Message` class: :rfc:`2231`, you can collapse the parameter value by calling :func:`email.utils.collapse_rfc2231_value`, passing in the return value from :meth:`get_param`. This will return a suitably decoded Unicode - string whn the value is a tuple, or the original string unquoted if it + string when the value is a tuple, or the original string unquoted if it isn't. For example:: rawparam = msg.get_param('foo') |