| Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{quopri} --- | 
| Fred Drake | 180b68b | 1999-02-22 13:45:09 +0000 | [diff] [blame] | 2 |          Encode and decode MIME quoted-printable data} | 
| Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 |  | 
| Fred Drake | 180b68b | 1999-02-22 13:45:09 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{quopri} | 
| Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 5 | \modulesynopsis{Encode and decode files using the MIME | 
| Fred Drake | ffbe687 | 1999-04-22 21:23:22 +0000 | [diff] [blame] | 6 |                 quoted-printable encoding.} | 
| Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 7 |  | 
| Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 8 |  | 
 | 9 | This module performs quoted-printable transport encoding and decoding, | 
| Martin v. Löwis | 16dc7f4 | 2001-09-30 20:32:11 +0000 | [diff] [blame] | 10 | as defined in \rfc{1521}: ``MIME (Multipurpose Internet Mail | 
 | 11 | Extensions) Part One: Mechanisms for Specifying and Describing the | 
 | 12 | Format of Internet Message Bodies''.  The quoted-printable encoding is | 
 | 13 | designed for data where there are relatively few nonprintable | 
 | 14 | characters; the base64 encoding scheme available via the | 
 | 15 | \refmodule{base64} module is more compact if there are many such | 
 | 16 | characters, as when sending a graphics file. | 
| Fred Drake | d59db4f | 1998-04-03 07:06:56 +0000 | [diff] [blame] | 17 | \indexii{quoted-printable}{encoding} | 
| Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 18 | \index{MIME!quoted-printable encoding} | 
 | 19 |  | 
| Fred Drake | 798654f | 1997-11-30 05:53:22 +0000 | [diff] [blame] | 20 |  | 
| Martin v. Löwis | 16dc7f4 | 2001-09-30 20:32:11 +0000 | [diff] [blame] | 21 | \begin{funcdesc}{decode}{input, output\optional{,header}} | 
| Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 22 | Decode the contents of the \var{input} file and write the resulting | 
 | 23 | decoded binary data to the \var{output} file. | 
 | 24 | \var{input} and \var{output} must either be file objects or objects that | 
 | 25 | mimic the file object interface. \var{input} will be read until | 
| Barry Warsaw | 6016e39 | 2001-06-19 19:44:42 +0000 | [diff] [blame] | 26 | \code{\var{input}.readline()} returns an empty string. | 
| Martin v. Löwis | 16dc7f4 | 2001-09-30 20:32:11 +0000 | [diff] [blame] | 27 | If the optional argument \var{header} is present and true, underscore | 
 | 28 | will be decoded as space. This is used to decode | 
 | 29 | ``Q''-encoded headers as described in \rfc{1522}: ``MIME (Multipurpose Internet Mail Extensions) | 
 | 30 | Part Two: Message Header Extensions for Non-ASCII Text''. | 
| Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 31 | \end{funcdesc} | 
 | 32 |  | 
| Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 33 | \begin{funcdesc}{encode}{input, output, quotetabs} | 
| Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 34 | Encode the contents of the \var{input} file and write the resulting | 
 | 35 | quoted-printable data to the \var{output} file. | 
 | 36 | \var{input} and \var{output} must either be file objects or objects that | 
 | 37 | mimic the file object interface. \var{input} will be read until | 
| Barry Warsaw | 6016e39 | 2001-06-19 19:44:42 +0000 | [diff] [blame] | 38 | \code{\var{input}.readline()} returns an empty string. | 
 | 39 | \var{quotetabs} is a flag which controls whether to encode embedded | 
 | 40 | spaces and tabs; when true it encodes such embedded whitespace, and | 
 | 41 | when false it leaves them unencoded.  Note that spaces and tabs | 
 | 42 | appearing at the end of lines are always encoded, as per \rfc{1521}. | 
 | 43 | \end{funcdesc} | 
 | 44 |  | 
| Martin v. Löwis | 16dc7f4 | 2001-09-30 20:32:11 +0000 | [diff] [blame] | 45 | \begin{funcdesc}{decodestring}{s\optional{,header}} | 
| Barry Warsaw | 6016e39 | 2001-06-19 19:44:42 +0000 | [diff] [blame] | 46 | Like \function{decode()}, except that it accepts a source string and | 
 | 47 | returns the corresponding decoded string. | 
 | 48 | \end{funcdesc} | 
 | 49 |  | 
 | 50 | \begin{funcdesc}{encodestring}{s\optional{, quotetabs}} | 
 | 51 | Like \function{encode()}, except that it accepts a source string and | 
 | 52 | returns the corresponding encoded string.  \var{quotetabs} is optional | 
 | 53 | (defaulting to 0), and is passed straight through to | 
 | 54 | \function{encode()}. | 
| Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 55 | \end{funcdesc} | 
 | 56 |  | 
 | 57 |  | 
| Fred Drake | 12ed365 | 2000-04-04 20:43:50 +0000 | [diff] [blame] | 58 | \begin{seealso} | 
 | 59 |   \seemodule{mimify}{General utilities for processing of MIME messages.} | 
| Barry Warsaw | 6016e39 | 2001-06-19 19:44:42 +0000 | [diff] [blame] | 60 |   \seemodule{base64}{Encode and decode MIME base64 data} | 
| Fred Drake | 12ed365 | 2000-04-04 20:43:50 +0000 | [diff] [blame] | 61 | \end{seealso} |