| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-uu.html" /> |
| 13 | <link rel="prev" href="module-binhex.html" /> |
| 14 | <link rel="parent" href="netdata.html" /> |
| 15 | <link rel="next" href="module-uu.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>12.15 quopri -- Encode and decode MIME quoted-printable data</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="12.14.1 Notes" |
| 25 | href="binhex-notes.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="12. Internet Data Handling" |
| 28 | href="netdata.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="12.16 uu " |
| 31 | href="module-uu.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="binhex-notes.html">12.14.1 Notes</A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="netdata.html">12. Internet Data Handling</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="module-uu.html">12.16 uu </A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION00141500000000000000000"> |
| 56 | 12.15 <tt class="module">quopri</tt> -- |
| 57 | Encode and decode MIME quoted-printable data</A> |
| 58 | </H1> |
| 59 | |
| 60 | <P> |
| 61 | <A NAME="module-quopri"></A> |
| 62 | |
| 63 | <P> |
| 64 | This module performs quoted-printable transport encoding and decoding, |
| 65 | as defined in <a class="rfc" id='rfcref-91270' xml:id='rfcref-91270' |
| 66 | href="http://www.faqs.org/rfcs/rfc1521.html">RFC 1521</a>: ``MIME (Multipurpose Internet Mail |
| 67 | Extensions) Part One: Mechanisms for Specifying and Describing the |
| 68 | Format of Internet Message Bodies''. The quoted-printable encoding is |
| 69 | designed for data where there are relatively few nonprintable |
| 70 | characters; the base64 encoding scheme available via the |
| 71 | <tt class="module"><a href="module-base64.html">base64</a></tt> module is more compact if there are many such |
| 72 | characters, as when sending a graphics file. |
| 73 | <a id='l2h-4150' xml:id='l2h-4150'></a><a id='l2h-4155' xml:id='l2h-4155'></a> |
| 74 | |
| 75 | <P> |
| 76 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 77 | <td><nobr><b><tt id='l2h-4151' xml:id='l2h-4151' class="function">decode</tt></b>(</nobr></td> |
| 78 | <td><var>input, output</var><big>[</big><var>,header</var><big>]</big><var></var>)</td></tr></table></dt> |
| 79 | <dd> |
| 80 | Decode the contents of the <var>input</var> file and write the resulting |
| 81 | decoded binary data to the <var>output</var> file. |
| 82 | <var>input</var> and <var>output</var> must either be file objects or objects that |
| 83 | mimic the file object interface. <var>input</var> will be read until |
| 84 | <code><var>input</var>.readline()</code> returns an empty string. |
| 85 | If the optional argument <var>header</var> is present and true, underscore |
| 86 | will be decoded as space. This is used to decode |
| 87 | ``Q''-encoded headers as described in <a class="rfc" id='rfcref-91273' xml:id='rfcref-91273' |
| 88 | href="http://www.faqs.org/rfcs/rfc1522.html">RFC 1522</a>: ``MIME (Multipurpose Internet Mail Extensions) |
| 89 | Part Two: Message Header Extensions for Non-ASCII Text''. |
| 90 | </dl> |
| 91 | |
| 92 | <P> |
| 93 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 94 | <td><nobr><b><tt id='l2h-4152' xml:id='l2h-4152' class="function">encode</tt></b>(</nobr></td> |
| 95 | <td><var>input, output, quotetabs</var>)</td></tr></table></dt> |
| 96 | <dd> |
| 97 | Encode the contents of the <var>input</var> file and write the resulting |
| 98 | quoted-printable data to the <var>output</var> file. |
| 99 | <var>input</var> and <var>output</var> must either be file objects or objects that |
| 100 | mimic the file object interface. <var>input</var> will be read until |
| 101 | <code><var>input</var>.readline()</code> returns an empty string. |
| 102 | <var>quotetabs</var> is a flag which controls whether to encode embedded |
| 103 | spaces and tabs; when true it encodes such embedded whitespace, and |
| 104 | when false it leaves them unencoded. Note that spaces and tabs |
| 105 | appearing at the end of lines are always encoded, as per <a class="rfc" id='rfcref-91275' xml:id='rfcref-91275' |
| 106 | href="http://www.faqs.org/rfcs/rfc1521.html">RFC 1521</a>. |
| 107 | </dl> |
| 108 | |
| 109 | <P> |
| 110 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 111 | <td><nobr><b><tt id='l2h-4153' xml:id='l2h-4153' class="function">decodestring</tt></b>(</nobr></td> |
| 112 | <td><var>s</var><big>[</big><var>,header</var><big>]</big><var></var>)</td></tr></table></dt> |
| 113 | <dd> |
| 114 | Like <tt class="function">decode()</tt>, except that it accepts a source string and |
| 115 | returns the corresponding decoded string. |
| 116 | </dl> |
| 117 | |
| 118 | <P> |
| 119 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 120 | <td><nobr><b><tt id='l2h-4154' xml:id='l2h-4154' class="function">encodestring</tt></b>(</nobr></td> |
| 121 | <td><var>s</var><big>[</big><var>, quotetabs</var><big>]</big><var></var>)</td></tr></table></dt> |
| 122 | <dd> |
| 123 | Like <tt class="function">encode()</tt>, except that it accepts a source string and |
| 124 | returns the corresponding encoded string. <var>quotetabs</var> is optional |
| 125 | (defaulting to 0), and is passed straight through to |
| 126 | <tt class="function">encode()</tt>. |
| 127 | </dl> |
| 128 | |
| 129 | <P> |
| 130 | <div class="seealso"> |
| 131 | <p class="heading">See Also:</p> |
| 132 | |
| 133 | <dl compact="compact" class="seemodule"> |
| 134 | <dt>Module <b><tt class="module"><a href="module-mimify.html">mimify</a></tt>:</b> |
| 135 | <dd>General utilities for processing of MIME messages. |
| 136 | </dl> |
| 137 | <dl compact="compact" class="seemodule"> |
| 138 | <dt>Module <b><tt class="module"><a href="module-base64.html">base64</a></tt>:</b> |
| 139 | <dd>Encode and decode MIME base64 data. |
| 140 | </dl> |
| 141 | </div> |
| 142 | |
| 143 | <DIV CLASS="navigation"> |
| 144 | <div class='online-navigation'> |
| 145 | <p></p><hr /> |
| 146 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 147 | <tr> |
| 148 | <td class='online-navigation'><a rel="prev" title="12.14.1 Notes" |
| 149 | href="binhex-notes.html"><img src='../icons/previous.png' |
| 150 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 151 | <td class='online-navigation'><a rel="parent" title="12. Internet Data Handling" |
| 152 | href="netdata.html"><img src='../icons/up.png' |
| 153 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 154 | <td class='online-navigation'><a rel="next" title="12.16 uu " |
| 155 | href="module-uu.html"><img src='../icons/next.png' |
| 156 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 157 | <td align="center" width="100%">Python Library Reference</td> |
| 158 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 159 | href="contents.html"><img src='../icons/contents.png' |
| 160 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 161 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 162 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 163 | <td class='online-navigation'><a rel="index" title="Index" |
| 164 | href="genindex.html"><img src='../icons/index.png' |
| 165 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 166 | </tr></table> |
| 167 | <div class='online-navigation'> |
| 168 | <b class="navlabel">Previous:</b> |
| 169 | <a class="sectref" rel="prev" href="binhex-notes.html">12.14.1 Notes</A> |
| 170 | <b class="navlabel">Up:</b> |
| 171 | <a class="sectref" rel="parent" href="netdata.html">12. Internet Data Handling</A> |
| 172 | <b class="navlabel">Next:</b> |
| 173 | <a class="sectref" rel="next" href="module-uu.html">12.16 uu </A> |
| 174 | </div> |
| 175 | </div> |
| 176 | <hr /> |
| 177 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 178 | </DIV> |
| 179 | <!--End of Navigation Panel--> |
| 180 | <ADDRESS> |
| 181 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 182 | </ADDRESS> |
| 183 | </BODY> |
| 184 | </HTML> |