aboutsummaryrefslogtreecommitdiff
path: root/docs/mime.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/mime.html (renamed from doc/mime.html)339
1 files changed, 170 insertions, 169 deletions
diff --git a/doc/mime.html b/docs/mime.html
index ae136fd..ff4d8e8 100644
--- a/doc/mime.html
+++ b/docs/mime.html
@@ -1,10 +1,10 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd"> 2 "http://www.w3.org/TR/html4/strict.dtd">
3<html> 3<html>
4 4
5<head> 5<head>
6<meta name="description" content="LuaSocket: MIME support"> 6<meta name="description" content="LuaSocket: MIME support">
7<meta name="keywords" content="Lua, LuaSocket, MIME, Library, Support"> 7<meta name="keywords" content="Lua, LuaSocket, MIME, Library, Support">
8<title>LuaSocket: MIME module</title> 8<title>LuaSocket: MIME module</title>
9<link rel="stylesheet" href="reference.css" type="text/css"> 9<link rel="stylesheet" href="reference.css" type="text/css">
10</head> 10</head>
@@ -13,22 +13,22 @@
13 13
14<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 14<!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
15 15
16<div class=header> 16<div class="header">
17<hr> 17<hr>
18<center> 18<center>
19<table summary="LuaSocket logo"> 19<table summary="LuaSocket logo">
20<tr><td align=center><a href="http://www.lua.org"> 20<tr><td align="center"><a href="http://www.lua.org">
21<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> 21<img width="128" height="128" border="0" alt="LuaSocket" src="luasocket.png">
22</a></td></tr> 22</a></td></tr>
23<tr><td align=center valign=top>Network support for the Lua language 23<tr><td align="center" valign="top">Network support for the Lua language
24</td></tr> 24</td></tr>
25</table> 25</table>
26<p class=bar> 26<p class="bar">
27<a href="index.html">home</a> &middot; 27<a href="index.html">home</a> &middot;
28<a href="index.html#download">download</a> &middot; 28<a href="index.html#download">download</a> &middot;
29<a href="installation.html">installation</a> &middot; 29<a href="installation.html">installation</a> &middot;
30<a href="introduction.html">introduction</a> &middot; 30<a href="introduction.html">introduction</a> &middot;
31<a href="reference.html">reference</a> 31<a href="reference.html">reference</a>
32</p> 32</p>
33</center> 33</center>
34<hr> 34<hr>
@@ -36,14 +36,14 @@
36 36
37<!-- mime +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 37<!-- mime +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
38 38
39<h2 id=mime>MIME</h2> 39<h2 id="mime">MIME</h2>
40 40
41<p> 41<p>
42The <tt>mime</tt> namespace offers filters that apply and remove common 42The <tt>mime</tt> namespace offers filters that apply and remove common
43content transfer encodings, such as Base64 and Quoted-Printable. 43content transfer encodings, such as Base64 and Quoted-Printable.
44It also provides functions to break text into lines and change 44It also provides functions to break text into lines and change
45the end-of-line convention. 45the end-of-line convention.
46MIME is described mainly in 46MIME is described mainly in
47<a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>, 47<a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>,
48<a href="http://www.ietf.org/rfc/rfc2046.txt">2046</a>, 48<a href="http://www.ietf.org/rfc/rfc2046.txt">2046</a>,
49<a href="http://www.ietf.org/rfc/rfc2047.txt">2047</a>, 49<a href="http://www.ietf.org/rfc/rfc2047.txt">2047</a>,
@@ -52,17 +52,17 @@ MIME is described mainly in
52</p> 52</p>
53 53
54<p> 54<p>
55All functionality provided by the MIME module 55All functionality provided by the MIME module
56follows the ideas presented in 56follows the ideas presented in
57<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> 57<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
58LTN012, Filters sources and sinks</a>. 58LTN012, Filters sources and sinks</a>.
59</p> 59</p>
60 60
61<p> 61<p>
62To obtain the <tt>mime</tt> namespace, run: 62To obtain the <tt>mime</tt> namespace, run:
63</p> 63</p>
64 64
65<pre class=example> 65<pre class="example">
66-- loads the MIME module and everything it requires 66-- loads the MIME module and everything it requires
67local mime = require("mime") 67local mime = require("mime")
68</pre> 68</pre>
@@ -70,88 +70,60 @@ local mime = require("mime")
70 70
71<!-- High-level +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 71<!-- High-level +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
72 72
73<h3 id=high>High-level filters</h3> 73<h3 id="high">High-level filters</h3>
74
75<!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
76
77<p class=name id="normalize">
78mime.<b>normalize(</b>[marker]<b>)</b>
79</p>
80 74
81<p class=description>
82Converts most common end-of-line markers to a specific given marker.
83</p>
84
85<p class=parameters>
86<tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic
87end-of-line marker defined by the MIME standard.
88</p>
89
90<p class=return>
91The function returns a filter that performs the conversion.
92</p>
93
94<p class=note>
95Note: There is no perfect solution to this problem. Different end-of-line
96markers are an evil that will probably plague developers forever.
97This function, however, will work perfectly for text created with any of
98the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF),
99or the DOS (CRLF) conventions. Even if the data has mixed end-of-line
100markers, the function will still work well, although it doesn't
101guarantee that the number of empty lines will be correct.
102</p>
103 75
104<!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 76<!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
105 77
106<p class=name id="decode"> 78<p class="name" id="decode">
107mime.<b>decode(</b>"base64"<b>)</b><br> 79mime.<b>decode(</b>"base64"<b>)</b><br>
108mime.<b>decode(</b>"quoted-printable"<b>)</b> 80mime.<b>decode(</b>"quoted-printable"<b>)</b>
109</p> 81</p>
110 82
111<p class=description> 83<p class="description">
112Returns a filter that decodes data from a given transfer content 84Returns a filter that decodes data from a given transfer content
113encoding. 85encoding.
114</p> 86</p>
115 87
116<!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 88<!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
117 89
118<p class=name id="encode"> 90<p class="name" id="encode">
119mime.<b>encode(</b>"base64"<b>)</b><br> 91mime.<b>encode(</b>"base64"<b>)</b><br>
120mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b> 92mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b>
121</p> 93</p>
122 94
123<p class=description> 95<p class="description">
124Returns a filter that encodes data according to a given transfer content 96Returns a filter that encodes data according to a given transfer content
125encoding. 97encoding.
126</p> 98</p>
127 99
128<p class=parameters> 100<p class="parameters">
129In the Quoted-Printable case, the user can specify whether the data is 101In the Quoted-Printable case, the user can specify whether the data is
130textual or binary, by passing the <tt>mode</tt> strings "<tt>text</tt>" or 102textual or binary, by passing the <tt>mode</tt> strings "<tt>text</tt>" or
131"<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". 103"<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>".
132</p> 104</p>
133 105
134<p class=note> 106<p class="note">
135Although both transfer content encodings specify a limit for the line 107Although both transfer content encodings specify a limit for the line
136length, the encoding filters do <em>not</em> break text into lines (for 108length, the encoding filters do <em>not</em> break text into lines (for
137added flexibility). 109added flexibility).
138Below is a filter that converts binary data to the Base64 transfer content 110Below is a filter that converts binary data to the Base64 transfer content
139encoding and breaks it into lines of the correct size. 111encoding and breaks it into lines of the correct size.
140</p> 112</p>
141 113
142<pre class=example> 114<pre class="example">
143base64 = ltn12.filter.chain( 115base64 = ltn12.filter.chain(
144 mime.encode("base64"), 116 mime.encode("base64"),
145 mime.wrap("base64") 117 mime.wrap("base64")
146) 118)
147</pre> 119</pre>
148 120
149<p class=note> 121<p class="note">
150Note: Text data <em>has</em> to be converted to canonic form 122Note: Text data <em>has</em> to be converted to canonic form
151<em>before</em> being encoded. 123<em>before</em> being encoded.
152</p> 124</p>
153 125
154<pre class=example> 126<pre class="example">
155base64 = ltn12.filter.chain( 127base64 = ltn12.filter.chain(
156 mime.normalize(), 128 mime.normalize(),
157 mime.encode("base64"), 129 mime.encode("base64"),
@@ -159,50 +131,79 @@ base64 = ltn12.filter.chain(
159) 131)
160</pre> 132</pre>
161 133
134<!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
135
136<p class="name" id="normalize">
137mime.<b>normalize(</b>[marker]<b>)</b>
138</p>
139
140<p class="description">
141Converts most common end-of-line markers to a specific given marker.
142</p>
143
144<p class="parameters">
145<tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic
146end-of-line marker defined by the MIME standard.
147</p>
148
149<p class="return">
150The function returns a filter that performs the conversion.
151</p>
152
153<p class="note">
154Note: There is no perfect solution to this problem. Different end-of-line
155markers are an evil that will probably plague developers forever.
156This function, however, will work perfectly for text created with any of
157the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF),
158or the DOS (CRLF) conventions. Even if the data has mixed end-of-line
159markers, the function will still work well, although it doesn't
160guarantee that the number of empty lines will be correct.
161</p>
162
162<!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 163<!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
163 164
164<p class=name id="stuff"> 165<p class="name" id="stuff">
165mime.<b>stuff()</b><br> 166mime.<b>stuff()</b><br>
166</p> 167</p>
167 168
168<p class=description> 169<p class="description">
169Creates and returns a filter that performs stuffing of SMTP messages. 170Creates and returns a filter that performs stuffing of SMTP messages.
170</p> 171</p>
171 172
172<p class=note> 173<p class="note">
173Note: The <a href=smtp.html#send><tt>smtp.send</tt></a> function 174Note: The <a href="smtp.html#send"><tt>smtp.send</tt></a> function
174uses this filter automatically. You don't need to chain it with your 175uses this filter automatically. You don't need to chain it with your
175source, or apply it to your message body. 176source, or apply it to your message body.
176</p> 177</p>
177 178
178<!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 179<!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
179 180
180<p class=name id="wrap"> 181<p class="name" id="wrap">
181mime.<b>wrap(</b>"text" [, length]<b>)</b><br> 182mime.<b>wrap(</b>"text" [, length]<b>)</b><br>
182mime.<b>wrap(</b>"base64"<b>)</b><br> 183mime.<b>wrap(</b>"base64"<b>)</b><br>
183mime.<b>wrap(</b>"quoted-printable"<b>)</b> 184mime.<b>wrap(</b>"quoted-printable"<b>)</b>
184</p> 185</p>
185 186
186<p class=description> 187<p class="description">
187Returns a filter that breaks data into lines. 188Returns a filter that breaks data into lines.
188</p> 189</p>
189 190
190<p class=parameters> 191<p class="parameters">
191The "<tt>text</tt>" line-wrap filter simply breaks text into lines by 192The "<tt>text</tt>" line-wrap filter simply breaks text into lines by
192inserting CRLF end-of-line markers at appropriate positions. 193inserting CRLF end-of-line markers at appropriate positions.
193<tt>Length</tt> defaults 76. 194<tt>Length</tt> defaults 76.
194The "<tt>base64</tt>" line-wrap filter works just like the default 195The "<tt>base64</tt>" line-wrap filter works just like the default
195"<tt>text</tt>" line-wrap filter with default length. 196"<tt>text</tt>" line-wrap filter with default length.
196The function can also wrap "<tt>quoted-printable</tt>" lines, taking care 197The function can also wrap "<tt>quoted-printable</tt>" lines, taking care
197not to break lines in the middle of an escaped character. In that case, the 198not to break lines in the middle of an escaped character. In that case, the
198line length is fixed at 76. 199line length is fixed at 76.
199</p> 200</p>
200 201
201<p class=note> 202<p class="note">
202For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following: 203For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following:
203</p> 204</p>
204 205
205<pre class=example> 206<pre class="example">
206qp = ltn12.filter.chain( 207qp = ltn12.filter.chain(
207 mime.normalize(), 208 mime.normalize(),
208 mime.encode("quoted-printable"), 209 mime.encode("quoted-printable"),
@@ -210,155 +211,155 @@ qp = ltn12.filter.chain(
210) 211)
211</pre> 212</pre>
212 213
213<p class=note> 214<p class="note">
214Note: To break into lines with a different end-of-line convention, apply 215Note: To break into lines with a different end-of-line convention, apply
215a normalization filter after the line break filter. 216a normalization filter after the line break filter.
216</p> 217</p>
217 218
218<!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 219<!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
219 220
220<h3 id=low>Low-level filters</h3> 221<h3 id="low">Low-level filters</h3>
221 222
222<!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 223<!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
223 224
224<p class=name id="b64"> 225<p class="name" id="b64">
225A, B = mime.<b>b64(</b>C [, D]<b>)</b> 226A, B = mime.<b>b64(</b>C [, D]<b>)</b>
226</p> 227</p>
227 228
228<p class=description> 229<p class="description">
229Low-level filter to perform Base64 encoding. 230Low-level filter to perform Base64 encoding.
230</p> 231</p>
231 232
232<p class=description> 233<p class="description">
233<tt>A</tt> is the encoded version of the largest prefix of 234<tt>A</tt> is the encoded version of the largest prefix of
234<tt>C..D</tt> 235<tt>C..D</tt>
235that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of 236that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of
236<tt>C..D</tt>, <em>before</em> encoding. 237<tt>C..D</tt>, <em>before</em> encoding.
237If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with 238If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with
238the encoding of the remaining bytes of <tt>C</tt>. 239the encoding of the remaining bytes of <tt>C</tt>.
239</p> 240</p>
240 241
241<p class=note> 242<p class="note">
242Note: The simplest use of this function is to encode a string into it's 243Note: The simplest use of this function is to encode a string into it's
243Base64 transfer content encoding. Notice the extra parenthesis around the 244Base64 transfer content encoding. Notice the extra parenthesis around the
244call to <tt>mime.b64</tt>, to discard the second return value. 245call to <tt>mime.b64</tt>, to discard the second return value.
245</p> 246</p>
246 247
247<pre class=example> 248<pre class="example">
248print((mime.b64("diego:password"))) 249print((mime.b64("diego:password")))
249--&gt; ZGllZ286cGFzc3dvcmQ= 250--&gt; ZGllZ286cGFzc3dvcmQ=
250</pre> 251</pre>
251 252
252<!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 253<!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
253<p class=name id="dot"> 254<p class="name" id="dot">
254A, n = mime.<b>dot(</b>m [, B]<b>)</b> 255A, n = mime.<b>dot(</b>m [, B]<b>)</b>
255</p> 256</p>
256 257
257<p class=description> 258<p class="description">
258Low-level filter to perform SMTP stuffing and enable transmission of 259Low-level filter to perform SMTP stuffing and enable transmission of
259messages containing the sequence "CRLF.CRLF". 260messages containing the sequence "CRLF.CRLF".
260</p> 261</p>
261 262
262<p class=parameters> 263<p class="parameters">
263<tt>A</tt> is the stuffed version of <tt>B</tt>. '<tt>n</tt>' gives the 264<tt>A</tt> is the stuffed version of <tt>B</tt>. '<tt>n</tt>' gives the
264number of characters from the sequence CRLF seen in the end of <tt>B</tt>. 265number of characters from the sequence CRLF seen in the end of <tt>B</tt>.
265'<tt>m</tt>' should tell the same, but for the previous chunk. 266'<tt>m</tt>' should tell the same, but for the previous chunk.
266</p> 267</p>
267 268
268<p class=note>Note: The message body is defined to begin with 269<p class="note">Note: The message body is defined to begin with
269an implicit CRLF. Therefore, to stuff a message correctly, the 270an implicit CRLF. Therefore, to stuff a message correctly, the
270first <tt>m</tt> should have the value 2. 271first <tt>m</tt> should have the value 2.
271</p> 272</p>
272 273
273<pre class=example> 274<pre class="example">
274print((string.gsub(mime.dot(2, ".\r\nStuffing the message.\r\n.\r\n."), "\r\n", "\\n"))) 275print((string.gsub(mime.dot(2, ".\r\nStuffing the message.\r\n.\r\n."), "\r\n", "\\n")))
275--&gt; ..\nStuffing the message.\n..\n.. 276--&gt; ..\nStuffing the message.\n..\n..
276</pre> 277</pre>
277 278
278<p class=note> 279<p class="note">
279Note: The <a href=smtp.html#send><tt>smtp.send</tt></a> function 280Note: The <a href="smtp.html#send"><tt>smtp.send</tt></a> function
280uses this filter automatically. You don't need to 281uses this filter automatically. You don't need to
281apply it again. 282apply it again.
282</p> 283</p>
283 284
284<!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 285<!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
285 286
286<p class=name id="eol"> 287<p class="name" id="eol">
287A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b> 288A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b>
288</p> 289</p>
289 290
290<p class=description> 291<p class="description">
291Low-level filter to perform end-of-line marker translation. 292Low-level filter to perform end-of-line marker translation.
292For each chunk, the function needs to know if the last character of the 293For each chunk, the function needs to know if the last character of the
293previous chunk could be part of an end-of-line marker or not. This is the 294previous chunk could be part of an end-of-line marker or not. This is the
294context the function receives besides the chunk. An updated version of 295context the function receives besides the chunk. An updated version of
295the context is returned after each new chunk. 296the context is returned after each new chunk.
296</p> 297</p>
297 298
298<p class=parameters> 299<p class="parameters">
299<tt>A</tt> is the translated version of <tt>D</tt>. <tt>C</tt> is the 300<tt>A</tt> is the translated version of <tt>D</tt>. <tt>C</tt> is the
300ASCII value of the last character of the previous chunk, if it was a 301ASCII value of the last character of the previous chunk, if it was a
301candidate for line break, or 0 otherwise. 302candidate for line break, or 0 otherwise.
302<tt>B</tt> is the same as <tt>C</tt>, but for the current 303<tt>B</tt> is the same as <tt>C</tt>, but for the current
303chunk. <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF. 304chunk. <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF.
304</p> 305</p>
305 306
306<pre class=example> 307<pre class="example">
307-- translates the end-of-line marker to UNIX 308-- translates the end-of-line marker to UNIX
308unix = mime.eol(0, dos, "\n") 309unix = mime.eol(0, dos, "\n")
309</pre> 310</pre>
310 311
311<!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 312<!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
312 313
313<p class=name id="qp"> 314<p class="name" id="qp">
314A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b> 315A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b>
315</p> 316</p>
316 317
317<p class=description> 318<p class="description">
318Low-level filter to perform Quoted-Printable encoding. 319Low-level filter to perform Quoted-Printable encoding.
319</p> 320</p>
320 321
321<p class=parameters> 322<p class="parameters">
322<tt>A</tt> is the encoded version of the largest prefix of 323<tt>A</tt> is the encoded version of the largest prefix of
323<tt>C..D</tt> 324<tt>C..D</tt>
324that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of 325that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of
325<tt>C..D</tt>, <em>before</em> encoding. 326<tt>C..D</tt>, <em>before</em> encoding.
326If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with 327If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with
327the encoding of the remaining bytes of <tt>C</tt>. 328the encoding of the remaining bytes of <tt>C</tt>.
328Throughout encoding, occurrences of CRLF are replaced by the 329Throughout encoding, occurrences of CRLF are replaced by the
329<tt>marker</tt>, which itself defaults to CRLF. 330<tt>marker</tt>, which itself defaults to CRLF.
330</p> 331</p>
331 332
332<p class=note> 333<p class="note">
333Note: The simplest use of this function is to encode a string into it's 334Note: The simplest use of this function is to encode a string into it's
334Quoted-Printable transfer content encoding. 335Quoted-Printable transfer content encoding.
335Notice the extra parenthesis around the call to <tt>mime.qp</tt>, to discard the second return value. 336Notice the extra parenthesis around the call to <tt>mime.qp</tt>, to discard the second return value.
336</p> 337</p>
337 338
338<pre class=example> 339<pre class="example">
339print((mime.qp("maçã"))) 340print((mime.qp("ma��")))
340--&gt; ma=E7=E3= 341--&gt; ma=E7=E3=
341</pre> 342</pre>
342 343
343<!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 344<!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
344 345
345<p class=name id="qpwrp"> 346<p class="name" id="qpwrp">
346A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b> 347A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b>
347</p> 348</p>
348 349
349<p class=description> 350<p class="description">
350Low-level filter to break Quoted-Printable text into lines. 351Low-level filter to break Quoted-Printable text into lines.
351</p> 352</p>
352 353
353<p class=parameters> 354<p class="parameters">
354<tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most 355<tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most
355<tt>length</tt> bytes (defaults to 76). 356<tt>length</tt> bytes (defaults to 76).
356'<tt>n</tt>' should tell how many bytes are left for the first 357'<tt>n</tt>' should tell how many bytes are left for the first
357line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes 358line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes
358left in the last line of <tt>A</tt>. 359left in the last line of <tt>A</tt>.
359</p> 360</p>
360 361
361<p class=note> 362<p class="note">
362Note: Besides breaking text into lines, this function makes sure the line 363Note: Besides breaking text into lines, this function makes sure the line
363breaks don't fall in the middle of an escaped character combination. Also, 364breaks don't fall in the middle of an escaped character combination. Also,
364this function only breaks lines that are bigger than <tt>length</tt> bytes. 365this function only breaks lines that are bigger than <tt>length</tt> bytes.
@@ -366,86 +367,86 @@ this function only breaks lines that are bigger than <tt>length</tt> bytes.
366 367
367<!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 368<!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
368 369
369<p class=name id="unb64"> 370<p class="name" id="unb64">
370A, B = mime.<b>unb64(</b>C [, D]<b>)</b> 371A, B = mime.<b>unb64(</b>C [, D]<b>)</b>
371</p> 372</p>
372 373
373<p class=description> 374<p class="description">
374Low-level filter to perform Base64 decoding. 375Low-level filter to perform Base64 decoding.
375</p> 376</p>
376 377
377<p class=parameters> 378<p class="parameters">
378<tt>A</tt> is the decoded version of the largest prefix of 379<tt>A</tt> is the decoded version of the largest prefix of
379<tt>C..D</tt> 380<tt>C..D</tt>
380that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of 381that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of
381<tt>C..D</tt>, <em>before</em> decoding. 382<tt>C..D</tt>, <em>before</em> decoding.
382If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is the empty string 383If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is the empty string
383and <tt>B</tt> returns whatever couldn't be decoded. 384and <tt>B</tt> returns whatever couldn't be decoded.
384</p> 385</p>
385 386
386<p class=note> 387<p class="note">
387Note: The simplest use of this function is to decode a string from it's 388Note: The simplest use of this function is to decode a string from it's
388Base64 transfer content encoding. 389Base64 transfer content encoding.
389Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value. 390Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value.
390</p> 391</p>
391 392
392<pre class=example> 393<pre class="example">
393print((mime.unb64("ZGllZ286cGFzc3dvcmQ="))) 394print((mime.unb64("ZGllZ286cGFzc3dvcmQ=")))
394--&gt; diego:password 395--&gt; diego:password
395</pre> 396</pre>
396 397
397<!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 398<!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
398 399
399<p class=name id="unqp"> 400<p class="name" id="unqp">
400A, B = mime.<b>unqp(</b>C [, D]<b>)</b> 401A, B = mime.<b>unqp(</b>C [, D]<b>)</b>
401</p> 402</p>
402 403
403<p class=description> 404<p class="description">
404Low-level filter to remove the Quoted-Printable transfer content encoding 405Low-level filter to remove the Quoted-Printable transfer content encoding
405from data. 406from data.
406</p> 407</p>
407 408
408<p class=parameters> 409<p class="parameters">
409<tt>A</tt> is the decoded version of the largest prefix of 410<tt>A</tt> is the decoded version of the largest prefix of
410<tt>C..D</tt> 411<tt>C..D</tt>
411that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of 412that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of
412<tt>C..D</tt>, <em>before</em> decoding. 413<tt>C..D</tt>, <em>before</em> decoding.
413If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is augmented with 414If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is augmented with
414the encoding of the remaining bytes of <tt>C</tt>. 415the encoding of the remaining bytes of <tt>C</tt>.
415</p> 416</p>
416 417
417<p class=note> 418<p class="note">
418Note: The simplest use of this function is to decode a string from it's 419Note: The simplest use of this function is to decode a string from it's
419Quoted-Printable transfer content encoding. 420Quoted-Printable transfer content encoding.
420Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value. 421Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value.
421</p> 422</p>
422 423
423<pre class=example> 424<pre class="example">
424print((mime.qp("ma=E7=E3="))) 425print((mime.qp("ma=E7=E3=")))
425--&gt; maçã 426--&gt; ma��
426</pre> 427</pre>
427 428
428<!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 429<!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
429 430
430<p class=name id="wrp"> 431<p class="name" id="wrp">
431A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b> 432A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b>
432</p> 433</p>
433 434
434<p class=description> 435<p class="description">
435Low-level filter to break text into lines with CRLF marker. 436Low-level filter to break text into lines with CRLF marker.
436Text is assumed to be in the <a href=#normalize><tt>normalize</tt></a> form. 437Text is assumed to be in the <a href="#normalize"><tt>normalize</tt></a> form.
437</p> 438</p>
438 439
439<p class=parameters> 440<p class="parameters">
440<tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most 441<tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most
441<tt>length</tt> bytes (defaults to 76). 442<tt>length</tt> bytes (defaults to 76).
442'<tt>n</tt>' should tell how many bytes are left for the first 443'<tt>n</tt>' should tell how many bytes are left for the first
443line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes 444line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes
444left in the last line of <tt>A</tt>. 445left in the last line of <tt>A</tt>.
445</p> 446</p>
446 447
447<p class=note> 448<p class="note">
448Note: This function only breaks lines that are bigger than 449Note: This function only breaks lines that are bigger than
449<tt>length</tt> bytes. The resulting line length does not include the CRLF 450<tt>length</tt> bytes. The resulting line length does not include the CRLF
450marker. 451marker.
451</p> 452</p>
@@ -453,10 +454,10 @@ marker.
453 454
454<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 455<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
455 456
456<div class=footer> 457<div class="footer">
457<hr> 458<hr>
458<center> 459<center>
459<p class=bar> 460<p class="bar">
460<a href="index.html">home</a> &middot; 461<a href="index.html">home</a> &middot;
461<a href="index.html#down">download</a> &middot; 462<a href="index.html#down">download</a> &middot;
462<a href="installation.html">installation</a> &middot; 463<a href="installation.html">installation</a> &middot;
@@ -466,7 +467,7 @@ marker.
466<p> 467<p>
467<small> 468<small>
468Last modified by Diego Nehab on <br> 469Last modified by Diego Nehab on <br>
469Thu Apr 20 00:25:44 EDT 2006 470Fri Mar 4 15:19:17 BRT 2016
470</small> 471</small>
471</p> 472</p>
472</center> 473</center>