| field in *header_name*. The default *maxlinelen* is 76, and the default value |
| for *header_name* is ``None``, meaning it is not taken into account for the |
| first line of a long, split header. |
| |
| Optional *continuation_ws* must be :rfc:`2822`\ -compliant folding whitespace, |
| and is usually either a space or a hard tab character. This character will be |
| prepended to continuation lines. |
| |
n | Optional *errors* is passed straight through to the :meth:`append` method. |
n | Optional *errors* is passed straight through to the :meth:`append` method. |
| |
| |
n | .. method:: Header.append(s[, charset[, errors]]) |
n | .. method:: append(s[, charset[, errors]]) |
| |
n | Append the string *s* to the MIME header. |
n | Append the string *s* to the MIME header. |
| |
n | Optional *charset*, if given, should be a :class:`Charset` instance (see |
n | Optional *charset*, if given, should be a :class:`Charset` instance (see |
| :mod:`email.charset`) or the name of a character set, which will be converted to |
| :mod:`email.charset`) or the name of a character set, which will be |
| a :class:`Charset` instance. A value of ``None`` (the default) means that the |
| converted to a :class:`Charset` instance. A value of ``None`` (the |
| *charset* given in the constructor is used. |
| default) means that the *charset* given in the constructor is used. |
| |
n | *s* may be a byte string or a Unicode string. If it is a byte string (i.e. |
n | *s* may be a byte string or a Unicode string. If it is a byte string |
| ``isinstance(s, str)`` is true), then *charset* is the encoding of that byte |
| (i.e. ``isinstance(s, str)`` is true), then *charset* is the encoding of |
| string, and a :exc:`UnicodeError` will be raised if the string cannot be decoded |
| that byte string, and a :exc:`UnicodeError` will be raised if the string |
| with that character set. |
| cannot be decoded with that character set. |
| |
n | If *s* is a Unicode string, then *charset* is a hint specifying the character |
n | If *s* is a Unicode string, then *charset* is a hint specifying the |
| set of the characters in the string. In this case, when producing an |
| character set of the characters in the string. In this case, when |
| :rfc:`2822`\ -compliant header using :rfc:`2047` rules, the Unicode string will |
| producing an :rfc:`2822`\ -compliant header using :rfc:`2047` rules, the |
| be encoded using the following charsets in order: ``us-ascii``, the *charset* |
| Unicode string will be encoded using the following charsets in order: |
| hint, ``utf-8``. The first character set to not provoke a :exc:`UnicodeError` |
| ``us-ascii``, the *charset* hint, ``utf-8``. The first character set to |
| is used. |
| not provoke a :exc:`UnicodeError` is used. |
| |
n | Optional *errors* is passed through to any :func:`unicode` or |
n | Optional *errors* is passed through to any :func:`unicode` or |
| :func:`ustr.encode` call, and defaults to "strict". |
| :func:`ustr.encode` call, and defaults to "strict". |
| |
| |
n | .. method:: Header.encode([splitchars]) |
n | .. method:: encode([splitchars]) |
| |
n | Encode a message header into an RFC-compliant format, possibly wrapping long |
n | Encode a message header into an RFC-compliant format, possibly wrapping |
| lines and encapsulating non-ASCII parts in base64 or quoted-printable encodings. |
| long lines and encapsulating non-ASCII parts in base64 or quoted-printable |
| Optional *splitchars* is a string containing characters to split long ASCII |
| encodings. Optional *splitchars* is a string containing characters to |
| lines on, in rough support of :rfc:`2822`'s *highest level syntactic breaks*. |
| split long ASCII lines on, in rough support of :rfc:`2822`'s *highest |
| This doesn't affect :rfc:`2047` encoded lines. |
| level syntactic breaks*. This doesn't affect :rfc:`2047` encoded lines. |
| |
n | The :class:`Header` class also provides a number of methods to support standard |
n | The :class:`Header` class also provides a number of methods to support |
| operators and built-in functions. |
| standard operators and built-in functions. |
| |
| |
n | .. method:: Header.__str__() |
n | .. method:: __str__() |
| |
n | A synonym for :meth:`Header.encode`. Useful for ``str(aHeader)``. |
n | A synonym for :meth:`Header.encode`. Useful for ``str(aHeader)``. |
| |
| |
n | .. method:: Header.__unicode__() |
n | .. method:: __unicode__() |
| |
n | A helper for the built-in :func:`unicode` function. Returns the header as a |
n | A helper for the built-in :func:`unicode` function. Returns the header as |
| Unicode string. |
| a Unicode string. |
| |
| |
n | .. method:: Header.__eq__(other) |
n | .. method:: __eq__(other) |
| |
n | This method allows you to compare two :class:`Header` instances for equality. |
n | This method allows you to compare two :class:`Header` instances for |
| equality. |
| |
| |
n | .. method:: Header.__ne__(other) |
n | .. method:: __ne__(other) |
| |
t | This method allows you to compare two :class:`Header` instances for inequality. |
t | This method allows you to compare two :class:`Header` instances for |
| inequality. |
| |
| The :mod:`email.header` module also provides the following convenient functions. |
| |
| |
| .. function:: decode_header(header) |
| |
| Decode a message header value without converting the character set. The header |
| value is in *header*. |