Commit | Line | Data |
---|---|---|
86530b38 AT |
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="prev" href="module-unicodedata.html" /> | |
13 | <link rel="parent" href="strings.html" /> | |
14 | <link rel="next" href="misc.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>4.11 stringprep -- Internet String Preparation</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="4.10 unicodedata " | |
24 | href="module-unicodedata.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="4. String Services" | |
27 | href="strings.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="5. Miscellaneous Services" | |
30 | href="misc.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python Library Reference</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
37 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="module-unicodedata.html">4.10 unicodedata </A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="strings.html">4. String Services</A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="misc.html">5. Miscellaneous Services</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H1><A NAME="SECTION0061100000000000000000"> | |
55 | 4.11 <tt class="module">stringprep</tt> -- | |
56 | Internet String Preparation</A> | |
57 | </H1> | |
58 | ||
59 | <P> | |
60 | <A NAME="module-stringprep"></A> | |
61 | ||
62 | <P> | |
63 | When identifying things (such as host names) in the internet, it is | |
64 | often necessary to compare such identifications for | |
65 | ``equality''. Exactly how this comparison is executed may depend on | |
66 | the application domain, e.g. whether it should be case-insensitive or | |
67 | not. It may be also necessary to restrict the possible | |
68 | identifications, to allow only identifications consisting of | |
69 | ``printable'' characters. | |
70 | ||
71 | <P> | |
72 | <a class="rfc" id='rfcref-87139' xml:id='rfcref-87139' | |
73 | href="http://www.faqs.org/rfcs/rfc3454.html">RFC 3454</a> defines a procedure for ``preparing'' Unicode strings in | |
74 | internet protocols. Before passing strings onto the wire, they are | |
75 | processed with the preparation procedure, after which they have a | |
76 | certain normalized form. The RFC defines a set of tables, which can be | |
77 | combined into profiles. Each profile must define which tables it uses, | |
78 | and what other optional parts of the <code>stringprep</code> procedure are | |
79 | part of the profile. One example of a <code>stringprep</code> profile is | |
80 | <code>nameprep</code>, which is used for internationalized domain names. | |
81 | ||
82 | <P> | |
83 | The module <tt class="module">stringprep</tt> only exposes the tables from RFC | |
84 | 3454. As these tables would be very large to represent them as | |
85 | dictionaries or lists, the module uses the Unicode character database | |
86 | internally. The module source code itself was generated using the | |
87 | <code>mkstringprep.py</code> utility. | |
88 | ||
89 | <P> | |
90 | As a result, these tables are exposed as functions, not as data | |
91 | structures. There are two kinds of tables in the RFC: sets and | |
92 | mappings. For a set, <tt class="module">stringprep</tt> provides the ``characteristic | |
93 | function'', i.e. a function that returns true if the parameter is part | |
94 | of the set. For mappings, it provides the mapping function: given the | |
95 | key, it returns the associated value. Below is a list of all functions | |
96 | available in the module. | |
97 | ||
98 | <P> | |
99 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
100 | <td><nobr><b><tt id='l2h-1039' xml:id='l2h-1039' class="function">in_table_a1</tt></b>(</nobr></td> | |
101 | <td><var>code</var>)</td></tr></table></dt> | |
102 | <dd> | |
103 | Determine whether <var>code</var> is in tableA.1 (Unassigned code points | |
104 | in Unicode 3.2). | |
105 | </dl> | |
106 | ||
107 | <P> | |
108 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
109 | <td><nobr><b><tt id='l2h-1040' xml:id='l2h-1040' class="function">in_table_b1</tt></b>(</nobr></td> | |
110 | <td><var>code</var>)</td></tr></table></dt> | |
111 | <dd> | |
112 | Determine whether <var>code</var> is in tableB.1 (Commonly mapped to | |
113 | nothing). | |
114 | </dl> | |
115 | ||
116 | <P> | |
117 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
118 | <td><nobr><b><tt id='l2h-1041' xml:id='l2h-1041' class="function">map_table_b2</tt></b>(</nobr></td> | |
119 | <td><var>code</var>)</td></tr></table></dt> | |
120 | <dd> | |
121 | Return the mapped value for <var>code</var> according to tableB.2 | |
122 | (Mapping for case-folding used with NFKC). | |
123 | </dl> | |
124 | ||
125 | <P> | |
126 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
127 | <td><nobr><b><tt id='l2h-1042' xml:id='l2h-1042' class="function">map_table_b3</tt></b>(</nobr></td> | |
128 | <td><var>code</var>)</td></tr></table></dt> | |
129 | <dd> | |
130 | Return the mapped value for <var>code</var> according to tableB.3 | |
131 | (Mapping for case-folding used with no normalization). | |
132 | </dl> | |
133 | ||
134 | <P> | |
135 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
136 | <td><nobr><b><tt id='l2h-1043' xml:id='l2h-1043' class="function">in_table_c11</tt></b>(</nobr></td> | |
137 | <td><var>code</var>)</td></tr></table></dt> | |
138 | <dd> | |
139 | Determine whether <var>code</var> is in tableC.1.1 | |
140 | (ASCII space characters). | |
141 | </dl> | |
142 | ||
143 | <P> | |
144 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
145 | <td><nobr><b><tt id='l2h-1044' xml:id='l2h-1044' class="function">in_table_c12</tt></b>(</nobr></td> | |
146 | <td><var>code</var>)</td></tr></table></dt> | |
147 | <dd> | |
148 | Determine whether <var>code</var> is in tableC.1.2 | |
149 | (Non-ASCII space characters). | |
150 | </dl> | |
151 | ||
152 | <P> | |
153 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
154 | <td><nobr><b><tt id='l2h-1045' xml:id='l2h-1045' class="function">in_table_c11_c12</tt></b>(</nobr></td> | |
155 | <td><var>code</var>)</td></tr></table></dt> | |
156 | <dd> | |
157 | Determine whether <var>code</var> is in tableC.1 | |
158 | (Space characters, union of C.1.1 and C.1.2). | |
159 | </dl> | |
160 | ||
161 | <P> | |
162 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
163 | <td><nobr><b><tt id='l2h-1046' xml:id='l2h-1046' class="function">in_table_c21</tt></b>(</nobr></td> | |
164 | <td><var>code</var>)</td></tr></table></dt> | |
165 | <dd> | |
166 | Determine whether <var>code</var> is in tableC.2.1 | |
167 | (ASCII control characters). | |
168 | </dl> | |
169 | ||
170 | <P> | |
171 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
172 | <td><nobr><b><tt id='l2h-1047' xml:id='l2h-1047' class="function">in_table_c22</tt></b>(</nobr></td> | |
173 | <td><var>code</var>)</td></tr></table></dt> | |
174 | <dd> | |
175 | Determine whether <var>code</var> is in tableC.2.2 | |
176 | (Non-ASCII control characters). | |
177 | </dl> | |
178 | ||
179 | <P> | |
180 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
181 | <td><nobr><b><tt id='l2h-1048' xml:id='l2h-1048' class="function">in_table_c21_c22</tt></b>(</nobr></td> | |
182 | <td><var>code</var>)</td></tr></table></dt> | |
183 | <dd> | |
184 | Determine whether <var>code</var> is in tableC.2 | |
185 | (Control characters, union of C.2.1 and C.2.2). | |
186 | </dl> | |
187 | ||
188 | <P> | |
189 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
190 | <td><nobr><b><tt id='l2h-1049' xml:id='l2h-1049' class="function">in_table_c3</tt></b>(</nobr></td> | |
191 | <td><var>code</var>)</td></tr></table></dt> | |
192 | <dd> | |
193 | Determine whether <var>code</var> is in tableC.3 | |
194 | (Private use). | |
195 | </dl> | |
196 | ||
197 | <P> | |
198 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
199 | <td><nobr><b><tt id='l2h-1050' xml:id='l2h-1050' class="function">in_table_c4</tt></b>(</nobr></td> | |
200 | <td><var>code</var>)</td></tr></table></dt> | |
201 | <dd> | |
202 | Determine whether <var>code</var> is in tableC.4 | |
203 | (Non-character code points). | |
204 | </dl> | |
205 | ||
206 | <P> | |
207 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
208 | <td><nobr><b><tt id='l2h-1051' xml:id='l2h-1051' class="function">in_table_c5</tt></b>(</nobr></td> | |
209 | <td><var>code</var>)</td></tr></table></dt> | |
210 | <dd> | |
211 | Determine whether <var>code</var> is in tableC.5 | |
212 | (Surrogate codes). | |
213 | </dl> | |
214 | ||
215 | <P> | |
216 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
217 | <td><nobr><b><tt id='l2h-1052' xml:id='l2h-1052' class="function">in_table_c6</tt></b>(</nobr></td> | |
218 | <td><var>code</var>)</td></tr></table></dt> | |
219 | <dd> | |
220 | Determine whether <var>code</var> is in tableC.6 | |
221 | (Inappropriate for plain text). | |
222 | </dl> | |
223 | ||
224 | <P> | |
225 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
226 | <td><nobr><b><tt id='l2h-1053' xml:id='l2h-1053' class="function">in_table_c7</tt></b>(</nobr></td> | |
227 | <td><var>code</var>)</td></tr></table></dt> | |
228 | <dd> | |
229 | Determine whether <var>code</var> is in tableC.7 | |
230 | (Inappropriate for canonical representation). | |
231 | </dl> | |
232 | ||
233 | <P> | |
234 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
235 | <td><nobr><b><tt id='l2h-1054' xml:id='l2h-1054' class="function">in_table_c8</tt></b>(</nobr></td> | |
236 | <td><var>code</var>)</td></tr></table></dt> | |
237 | <dd> | |
238 | Determine whether <var>code</var> is in tableC.8 | |
239 | (Change display properties or are deprecated). | |
240 | </dl> | |
241 | ||
242 | <P> | |
243 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
244 | <td><nobr><b><tt id='l2h-1055' xml:id='l2h-1055' class="function">in_table_c9</tt></b>(</nobr></td> | |
245 | <td><var>code</var>)</td></tr></table></dt> | |
246 | <dd> | |
247 | Determine whether <var>code</var> is in tableC.9 | |
248 | (Tagging characters). | |
249 | </dl> | |
250 | ||
251 | <P> | |
252 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
253 | <td><nobr><b><tt id='l2h-1056' xml:id='l2h-1056' class="function">in_table_d1</tt></b>(</nobr></td> | |
254 | <td><var>code</var>)</td></tr></table></dt> | |
255 | <dd> | |
256 | Determine whether <var>code</var> is in tableD.1 | |
257 | (Characters with bidirectional property ``R'' or ``AL''). | |
258 | </dl> | |
259 | ||
260 | <P> | |
261 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
262 | <td><nobr><b><tt id='l2h-1057' xml:id='l2h-1057' class="function">in_table_d2</tt></b>(</nobr></td> | |
263 | <td><var>code</var>)</td></tr></table></dt> | |
264 | <dd> | |
265 | Determine whether <var>code</var> is in tableD.2 | |
266 | (Characters with bidirectional property ``L''). | |
267 | </dl> | |
268 | ||
269 | <P> | |
270 | ||
271 | <DIV CLASS="navigation"> | |
272 | <div class='online-navigation'> | |
273 | <p></p><hr /> | |
274 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
275 | <tr> | |
276 | <td class='online-navigation'><a rel="prev" title="4.10 unicodedata " | |
277 | href="module-unicodedata.html"><img src='../icons/previous.png' | |
278 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
279 | <td class='online-navigation'><a rel="parent" title="4. String Services" | |
280 | href="strings.html"><img src='../icons/up.png' | |
281 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
282 | <td class='online-navigation'><a rel="next" title="5. Miscellaneous Services" | |
283 | href="misc.html"><img src='../icons/next.png' | |
284 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
285 | <td align="center" width="100%">Python Library Reference</td> | |
286 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
287 | href="contents.html"><img src='../icons/contents.png' | |
288 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
289 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
290 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
291 | <td class='online-navigation'><a rel="index" title="Index" | |
292 | href="genindex.html"><img src='../icons/index.png' | |
293 | border='0' height='32' alt='Index' width='32' /></A></td> | |
294 | </tr></table> | |
295 | <div class='online-navigation'> | |
296 | <b class="navlabel">Previous:</b> | |
297 | <a class="sectref" rel="prev" href="module-unicodedata.html">4.10 unicodedata </A> | |
298 | <b class="navlabel">Up:</b> | |
299 | <a class="sectref" rel="parent" href="strings.html">4. String Services</A> | |
300 | <b class="navlabel">Next:</b> | |
301 | <a class="sectref" rel="next" href="misc.html">5. Miscellaneous Services</A> | |
302 | </div> | |
303 | </div> | |
304 | <hr /> | |
305 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
306 | </DIV> | |
307 | <!--End of Navigation Panel--> | |
308 | <ADDRESS> | |
309 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
310 | </ADDRESS> | |
311 | </BODY> | |
312 | </HTML> |