87d70c382c6870698d02f22af543a0cff19e2bf8
[profile/ivi/python.git] / Doc / library / quopri.rst
1
2 :mod:`quopri` --- Encode and decode MIME quoted-printable data
3 ==============================================================
4
5 .. module:: quopri
6    :synopsis: Encode and decode files using the MIME quoted-printable encoding.
7
8
9 .. index::
10    pair: quoted-printable; encoding
11    single: MIME; quoted-printable encoding
12
13 This module performs quoted-printable transport encoding and decoding, as
14 defined in :rfc:`1521`: "MIME (Multipurpose Internet Mail Extensions) Part One:
15 Mechanisms for Specifying and Describing the Format of Internet Message Bodies".
16 The quoted-printable encoding is designed for data where there are relatively
17 few nonprintable characters; the base64 encoding scheme available via the
18 :mod:`base64` module is more compact if there are many such characters, as when
19 sending a graphics file.
20
21 .. seealso::
22
23    Latest version of the `quopri module Python source code
24    <http://svn.python.org/view/python/branches/release27-maint/Lib/quopri.py?view=markup>`_
25
26 .. function:: decode(input, output[,header])
27
28    Decode the contents of the *input* file and write the resulting decoded binary
29    data to the *output* file. *input* and *output* must either be file objects or
30    objects that mimic the file object interface. *input* will be read until
31    ``input.readline()`` returns an empty string. If the optional argument *header*
32    is present and true, underscore will be decoded as space. This is used to decode
33    "Q"-encoded headers as described in :rfc:`1522`: "MIME (Multipurpose Internet
34    Mail Extensions) Part Two: Message Header Extensions for Non-ASCII Text".
35
36
37 .. function:: encode(input, output, quotetabs)
38
39    Encode the contents of the *input* file and write the resulting quoted-printable
40    data to the *output* file. *input* and *output* must either be file objects or
41    objects that mimic the file object interface. *input* will be read until
42    ``input.readline()`` returns an empty string. *quotetabs* is a flag which
43    controls whether to encode embedded spaces and tabs; when true it encodes such
44    embedded whitespace, and when false it leaves them unencoded.  Note that spaces
45    and tabs appearing at the end of lines are always encoded, as per :rfc:`1521`.
46
47
48 .. function:: decodestring(s[,header])
49
50    Like :func:`decode`, except that it accepts a source string and returns the
51    corresponding decoded string.
52
53
54 .. function:: encodestring(s[, quotetabs])
55
56    Like :func:`encode`, except that it accepts a source string and returns the
57    corresponding encoded string.  *quotetabs* is optional (defaulting to 0), and is
58    passed straight through to :func:`encode`.
59
60
61 .. seealso::
62
63    Module :mod:`mimify`
64       General utilities for processing of MIME messages.
65
66    Module :mod:`base64`
67       Encode and decode MIME base64 data
68