blob: 9e7895bd9bdfae35614ee67f6e2645ddb3e76185 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{quopri} ---
Fred Drake180b68b1999-02-22 13:45:09 +00002 Encode and decode MIME quoted-printable data}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drake180b68b1999-02-22 13:45:09 +00004\declaremodule{standard}{quopri}
Fred Drake295da241998-08-10 19:42:37 +00005\modulesynopsis{Encode and decode files using the MIME
Fred Drakeffbe6871999-04-22 21:23:22 +00006 quoted-printable encoding.}
Fred Drakeb91e9341998-07-23 17:59:49 +00007
Guido van Rossume76b7a81997-04-27 21:25:52 +00008
9This module performs quoted-printable transport encoding and decoding,
Martin v. Löwis16dc7f42001-09-30 20:32:11 +000010as defined in \rfc{1521}: ``MIME (Multipurpose Internet Mail
11Extensions) Part One: Mechanisms for Specifying and Describing the
12Format of Internet Message Bodies''. The quoted-printable encoding is
13designed for data where there are relatively few nonprintable
14characters; the base64 encoding scheme available via the
15\refmodule{base64} module is more compact if there are many such
16characters, as when sending a graphics file.
Fred Draked59db4f1998-04-03 07:06:56 +000017\indexii{quoted-printable}{encoding}
Guido van Rossume76b7a81997-04-27 21:25:52 +000018\index{MIME!quoted-printable encoding}
19
Fred Drake798654f1997-11-30 05:53:22 +000020
Martin v. Löwis16dc7f42001-09-30 20:32:11 +000021\begin{funcdesc}{decode}{input, output\optional{,header}}
Guido van Rossume76b7a81997-04-27 21:25:52 +000022Decode the contents of the \var{input} file and write the resulting
23decoded binary data to the \var{output} file.
24\var{input} and \var{output} must either be file objects or objects that
25mimic the file object interface. \var{input} will be read until
Barry Warsaw6016e392001-06-19 19:44:42 +000026\code{\var{input}.readline()} returns an empty string.
Martin v. Löwis16dc7f42001-09-30 20:32:11 +000027If the optional argument \var{header} is present and true, underscore
28will be decoded as space. This is used to decode
29``Q''-encoded headers as described in \rfc{1522}: ``MIME (Multipurpose Internet Mail Extensions)
30Part Two: Message Header Extensions for Non-ASCII Text''.
Guido van Rossume76b7a81997-04-27 21:25:52 +000031\end{funcdesc}
32
Fred Drakecce10901998-03-17 06:33:25 +000033\begin{funcdesc}{encode}{input, output, quotetabs}
Guido van Rossume76b7a81997-04-27 21:25:52 +000034Encode the contents of the \var{input} file and write the resulting
35quoted-printable data to the \var{output} file.
36\var{input} and \var{output} must either be file objects or objects that
37mimic the file object interface. \var{input} will be read until
Barry Warsaw6016e392001-06-19 19:44:42 +000038\code{\var{input}.readline()} returns an empty string.
39\var{quotetabs} is a flag which controls whether to encode embedded
40spaces and tabs; when true it encodes such embedded whitespace, and
41when false it leaves them unencoded. Note that spaces and tabs
42appearing at the end of lines are always encoded, as per \rfc{1521}.
43\end{funcdesc}
44
Martin v. Löwis16dc7f42001-09-30 20:32:11 +000045\begin{funcdesc}{decodestring}{s\optional{,header}}
Barry Warsaw6016e392001-06-19 19:44:42 +000046Like \function{decode()}, except that it accepts a source string and
47returns the corresponding decoded string.
48\end{funcdesc}
49
50\begin{funcdesc}{encodestring}{s\optional{, quotetabs}}
51Like \function{encode()}, except that it accepts a source string and
52returns the corresponding encoded string. \var{quotetabs} is optional
53(defaulting to 0), and is passed straight through to
54\function{encode()}.
Guido van Rossume76b7a81997-04-27 21:25:52 +000055\end{funcdesc}
56
57
Fred Drake12ed3652000-04-04 20:43:50 +000058\begin{seealso}
59 \seemodule{mimify}{General utilities for processing of MIME messages.}
Barry Warsaw6016e392001-06-19 19:44:42 +000060 \seemodule{base64}{Encode and decode MIME base64 data}
Fred Drake12ed3652000-04-04 20:43:50 +000061\end{seealso}