~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.11-docs-html/library/stringprep.html

  • Committer: Dave Kuhlman
  • Date: 2016-02-11 21:17:09 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20160211211709-03yaen3cjempbi2m
Updated Python 2.7 docs; added Python 3.5 docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>7.10. stringprep — Internet String Preparation &mdash; Python 2.7.11 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '2.7.11',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
23
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
24
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
25
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
26
    <script type="text/javascript" src="../_static/sidebar.js"></script>
 
27
    <link rel="search" type="application/opensearchdescription+xml"
 
28
          title="Search within Python 2.7.11 documentation"
 
29
          href="../_static/opensearch.xml"/>
 
30
    <link rel="author" title="About these documents" href="../about.html" />
 
31
    <link rel="copyright" title="Copyright" href="../copyright.html" />
 
32
    <link rel="top" title="Python 2.7.11 documentation" href="../contents.html" />
 
33
    <link rel="up" title="7. String Services" href="strings.html" />
 
34
    <link rel="next" title="7.11. fpformat — Floating point conversions" href="fpformat.html" />
 
35
    <link rel="prev" title="7.9. unicodedata — Unicode Database" href="unicodedata.html" />
 
36
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 
37
    <script type="text/javascript" src="../_static/copybutton.js"></script>
 
38
    <script type="text/javascript" src="../_static/version_switch.js"></script>
 
39
 
 
40
    
 
41
 
 
42
  </head>
 
43
  <body role="document">  
 
44
    <div class="related" role="navigation" aria-label="related navigation">
 
45
      <h3>Navigation</h3>
 
46
      <ul>
 
47
        <li class="right" style="margin-right: 10px">
 
48
          <a href="../genindex.html" title="General Index"
 
49
             accesskey="I">index</a></li>
 
50
        <li class="right" >
 
51
          <a href="../py-modindex.html" title="Python Module Index"
 
52
             >modules</a> |</li>
 
53
        <li class="right" >
 
54
          <a href="fpformat.html" title="7.11. fpformat — Floating point conversions"
 
55
             accesskey="N">next</a> |</li>
 
56
        <li class="right" >
 
57
          <a href="unicodedata.html" title="7.9. unicodedata — Unicode Database"
 
58
             accesskey="P">previous</a> |</li>
 
59
        <li><img src="../_static/py.png" alt=""
 
60
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
61
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
62
        <li>
 
63
          <span class="version_switcher_placeholder">2.7.11</span>
 
64
          <a href="../index.html">Documentation</a> &raquo;
 
65
        </li>
 
66
 
 
67
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
 
68
          <li class="nav-item nav-item-2"><a href="strings.html" accesskey="U">7. String Services</a> &raquo;</li> 
 
69
      </ul>
 
70
    </div>    
 
71
 
 
72
    <div class="document">
 
73
      <div class="documentwrapper">
 
74
        <div class="bodywrapper">
 
75
          <div class="body" role="main">
 
76
            
 
77
  <div class="section" id="module-stringprep">
 
78
<span id="stringprep-internet-string-preparation"></span><h1>7.10. <a class="reference internal" href="#module-stringprep" title="stringprep: String preparation, as per RFC 3453"><code class="xref py py-mod docutils literal"><span class="pre">stringprep</span></code></a> &#8212; Internet String Preparation<a class="headerlink" href="#module-stringprep" title="Permalink to this headline">¶</a></h1>
 
79
<div class="versionadded">
 
80
<p><span class="versionmodified">New in version 2.3.</span></p>
 
81
</div>
 
82
<p>When identifying things (such as host names) in the internet, it is often
 
83
necessary to compare such identifications for &#8220;equality&#8221;. Exactly how this
 
84
comparison is executed may depend on the application domain, e.g. whether it
 
85
should be case-insensitive or not. It may be also necessary to restrict the
 
86
possible identifications, to allow only identifications consisting of
 
87
&#8220;printable&#8221; characters.</p>
 
88
<p><span class="target" id="index-0"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc3454.html"><strong>RFC 3454</strong></a> defines a procedure for &#8220;preparing&#8221; Unicode strings in internet
 
89
protocols. Before passing strings onto the wire, they are processed with the
 
90
preparation procedure, after which they have a certain normalized form. The RFC
 
91
defines a set of tables, which can be combined into profiles. Each profile must
 
92
define which tables it uses, and what other optional parts of the <code class="docutils literal"><span class="pre">stringprep</span></code>
 
93
procedure are part of the profile. One example of a <code class="docutils literal"><span class="pre">stringprep</span></code> profile is
 
94
<code class="docutils literal"><span class="pre">nameprep</span></code>, which is used for internationalized domain names.</p>
 
95
<p>The module <a class="reference internal" href="#module-stringprep" title="stringprep: String preparation, as per RFC 3453"><code class="xref py py-mod docutils literal"><span class="pre">stringprep</span></code></a> only exposes the tables from RFC 3454. As these
 
96
tables would be very large to represent them as dictionaries or lists, the
 
97
module uses the Unicode character database internally. The module source code
 
98
itself was generated using the <code class="docutils literal"><span class="pre">mkstringprep.py</span></code> utility.</p>
 
99
<p>As a result, these tables are exposed as functions, not as data structures.
 
100
There are two kinds of tables in the RFC: sets and mappings. For a set,
 
101
<a class="reference internal" href="#module-stringprep" title="stringprep: String preparation, as per RFC 3453"><code class="xref py py-mod docutils literal"><span class="pre">stringprep</span></code></a> provides the &#8220;characteristic function&#8221;, i.e. a function that
 
102
returns true if the parameter is part of the set. For mappings, it provides the
 
103
mapping function: given the key, it returns the associated value. Below is a
 
104
list of all functions available in the module.</p>
 
105
<dl class="function">
 
106
<dt id="stringprep.in_table_a1">
 
107
<code class="descclassname">stringprep.</code><code class="descname">in_table_a1</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_a1" title="Permalink to this definition">¶</a></dt>
 
108
<dd><p>Determine whether <em>code</em> is in tableA.1 (Unassigned code points in Unicode 3.2).</p>
 
109
</dd></dl>
 
110
 
 
111
<dl class="function">
 
112
<dt id="stringprep.in_table_b1">
 
113
<code class="descclassname">stringprep.</code><code class="descname">in_table_b1</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_b1" title="Permalink to this definition">¶</a></dt>
 
114
<dd><p>Determine whether <em>code</em> is in tableB.1 (Commonly mapped to nothing).</p>
 
115
</dd></dl>
 
116
 
 
117
<dl class="function">
 
118
<dt id="stringprep.map_table_b2">
 
119
<code class="descclassname">stringprep.</code><code class="descname">map_table_b2</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.map_table_b2" title="Permalink to this definition">¶</a></dt>
 
120
<dd><p>Return the mapped value for <em>code</em> according to tableB.2 (Mapping for
 
121
case-folding used with NFKC).</p>
 
122
</dd></dl>
 
123
 
 
124
<dl class="function">
 
125
<dt id="stringprep.map_table_b3">
 
126
<code class="descclassname">stringprep.</code><code class="descname">map_table_b3</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.map_table_b3" title="Permalink to this definition">¶</a></dt>
 
127
<dd><p>Return the mapped value for <em>code</em> according to tableB.3 (Mapping for
 
128
case-folding used with no normalization).</p>
 
129
</dd></dl>
 
130
 
 
131
<dl class="function">
 
132
<dt id="stringprep.in_table_c11">
 
133
<code class="descclassname">stringprep.</code><code class="descname">in_table_c11</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c11" title="Permalink to this definition">¶</a></dt>
 
134
<dd><p>Determine whether <em>code</em> is in tableC.1.1  (ASCII space characters).</p>
 
135
</dd></dl>
 
136
 
 
137
<dl class="function">
 
138
<dt id="stringprep.in_table_c12">
 
139
<code class="descclassname">stringprep.</code><code class="descname">in_table_c12</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c12" title="Permalink to this definition">¶</a></dt>
 
140
<dd><p>Determine whether <em>code</em> is in tableC.1.2  (Non-ASCII space characters).</p>
 
141
</dd></dl>
 
142
 
 
143
<dl class="function">
 
144
<dt id="stringprep.in_table_c11_c12">
 
145
<code class="descclassname">stringprep.</code><code class="descname">in_table_c11_c12</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c11_c12" title="Permalink to this definition">¶</a></dt>
 
146
<dd><p>Determine whether <em>code</em> is in tableC.1  (Space characters, union of C.1.1 and
 
147
C.1.2).</p>
 
148
</dd></dl>
 
149
 
 
150
<dl class="function">
 
151
<dt id="stringprep.in_table_c21">
 
152
<code class="descclassname">stringprep.</code><code class="descname">in_table_c21</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c21" title="Permalink to this definition">¶</a></dt>
 
153
<dd><p>Determine whether <em>code</em> is in tableC.2.1  (ASCII control characters).</p>
 
154
</dd></dl>
 
155
 
 
156
<dl class="function">
 
157
<dt id="stringprep.in_table_c22">
 
158
<code class="descclassname">stringprep.</code><code class="descname">in_table_c22</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c22" title="Permalink to this definition">¶</a></dt>
 
159
<dd><p>Determine whether <em>code</em> is in tableC.2.2  (Non-ASCII control characters).</p>
 
160
</dd></dl>
 
161
 
 
162
<dl class="function">
 
163
<dt id="stringprep.in_table_c21_c22">
 
164
<code class="descclassname">stringprep.</code><code class="descname">in_table_c21_c22</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c21_c22" title="Permalink to this definition">¶</a></dt>
 
165
<dd><p>Determine whether <em>code</em> is in tableC.2  (Control characters, union of C.2.1 and
 
166
C.2.2).</p>
 
167
</dd></dl>
 
168
 
 
169
<dl class="function">
 
170
<dt id="stringprep.in_table_c3">
 
171
<code class="descclassname">stringprep.</code><code class="descname">in_table_c3</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c3" title="Permalink to this definition">¶</a></dt>
 
172
<dd><p>Determine whether <em>code</em> is in tableC.3  (Private use).</p>
 
173
</dd></dl>
 
174
 
 
175
<dl class="function">
 
176
<dt id="stringprep.in_table_c4">
 
177
<code class="descclassname">stringprep.</code><code class="descname">in_table_c4</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c4" title="Permalink to this definition">¶</a></dt>
 
178
<dd><p>Determine whether <em>code</em> is in tableC.4  (Non-character code points).</p>
 
179
</dd></dl>
 
180
 
 
181
<dl class="function">
 
182
<dt id="stringprep.in_table_c5">
 
183
<code class="descclassname">stringprep.</code><code class="descname">in_table_c5</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c5" title="Permalink to this definition">¶</a></dt>
 
184
<dd><p>Determine whether <em>code</em> is in tableC.5  (Surrogate codes).</p>
 
185
</dd></dl>
 
186
 
 
187
<dl class="function">
 
188
<dt id="stringprep.in_table_c6">
 
189
<code class="descclassname">stringprep.</code><code class="descname">in_table_c6</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c6" title="Permalink to this definition">¶</a></dt>
 
190
<dd><p>Determine whether <em>code</em> is in tableC.6  (Inappropriate for plain text).</p>
 
191
</dd></dl>
 
192
 
 
193
<dl class="function">
 
194
<dt id="stringprep.in_table_c7">
 
195
<code class="descclassname">stringprep.</code><code class="descname">in_table_c7</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c7" title="Permalink to this definition">¶</a></dt>
 
196
<dd><p>Determine whether <em>code</em> is in tableC.7  (Inappropriate for canonical
 
197
representation).</p>
 
198
</dd></dl>
 
199
 
 
200
<dl class="function">
 
201
<dt id="stringprep.in_table_c8">
 
202
<code class="descclassname">stringprep.</code><code class="descname">in_table_c8</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c8" title="Permalink to this definition">¶</a></dt>
 
203
<dd><p>Determine whether <em>code</em> is in tableC.8  (Change display properties or are
 
204
deprecated).</p>
 
205
</dd></dl>
 
206
 
 
207
<dl class="function">
 
208
<dt id="stringprep.in_table_c9">
 
209
<code class="descclassname">stringprep.</code><code class="descname">in_table_c9</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_c9" title="Permalink to this definition">¶</a></dt>
 
210
<dd><p>Determine whether <em>code</em> is in tableC.9  (Tagging characters).</p>
 
211
</dd></dl>
 
212
 
 
213
<dl class="function">
 
214
<dt id="stringprep.in_table_d1">
 
215
<code class="descclassname">stringprep.</code><code class="descname">in_table_d1</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_d1" title="Permalink to this definition">¶</a></dt>
 
216
<dd><p>Determine whether <em>code</em> is in tableD.1  (Characters with bidirectional property
 
217
&#8220;R&#8221; or &#8220;AL&#8221;).</p>
 
218
</dd></dl>
 
219
 
 
220
<dl class="function">
 
221
<dt id="stringprep.in_table_d2">
 
222
<code class="descclassname">stringprep.</code><code class="descname">in_table_d2</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#stringprep.in_table_d2" title="Permalink to this definition">¶</a></dt>
 
223
<dd><p>Determine whether <em>code</em> is in tableD.2  (Characters with bidirectional property
 
224
&#8220;L&#8221;).</p>
 
225
</dd></dl>
 
226
 
 
227
</div>
 
228
 
 
229
 
 
230
          </div>
 
231
        </div>
 
232
      </div>
 
233
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
 
234
        <div class="sphinxsidebarwrapper">
 
235
  <h4>Previous topic</h4>
 
236
  <p class="topless"><a href="unicodedata.html"
 
237
                        title="previous chapter">7.9. <code class="docutils literal"><span class="pre">unicodedata</span></code> &#8212; Unicode Database</a></p>
 
238
  <h4>Next topic</h4>
 
239
  <p class="topless"><a href="fpformat.html"
 
240
                        title="next chapter">7.11. <code class="docutils literal"><span class="pre">fpformat</span></code> &#8212; Floating point conversions</a></p>
 
241
<h3>This Page</h3>
 
242
<ul class="this-page-menu">
 
243
  <li><a href="../bugs.html">Report a Bug</a></li>
 
244
  <li><a href="../_sources/library/stringprep.txt"
 
245
         rel="nofollow">Show Source</a></li>
 
246
</ul>
 
247
 
 
248
<div id="searchbox" style="display: none" role="search">
 
249
  <h3>Quick search</h3>
 
250
    <form class="search" action="../search.html" method="get">
 
251
      <input type="text" name="q" />
 
252
      <input type="submit" value="Go" />
 
253
      <input type="hidden" name="check_keywords" value="yes" />
 
254
      <input type="hidden" name="area" value="default" />
 
255
    </form>
 
256
    <p class="searchtip" style="font-size: 90%">
 
257
    Enter search terms or a module, class or function name.
 
258
    </p>
 
259
</div>
 
260
<script type="text/javascript">$('#searchbox').show(0);</script>
 
261
        </div>
 
262
      </div>
 
263
      <div class="clearer"></div>
 
264
    </div>  
 
265
    <div class="related" role="navigation" aria-label="related navigation">
 
266
      <h3>Navigation</h3>
 
267
      <ul>
 
268
        <li class="right" style="margin-right: 10px">
 
269
          <a href="../genindex.html" title="General Index"
 
270
             >index</a></li>
 
271
        <li class="right" >
 
272
          <a href="../py-modindex.html" title="Python Module Index"
 
273
             >modules</a> |</li>
 
274
        <li class="right" >
 
275
          <a href="fpformat.html" title="7.11. fpformat — Floating point conversions"
 
276
             >next</a> |</li>
 
277
        <li class="right" >
 
278
          <a href="unicodedata.html" title="7.9. unicodedata — Unicode Database"
 
279
             >previous</a> |</li>
 
280
        <li><img src="../_static/py.png" alt=""
 
281
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
282
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
283
        <li>
 
284
          <span class="version_switcher_placeholder">2.7.11</span>
 
285
          <a href="../index.html">Documentation</a> &raquo;
 
286
        </li>
 
287
 
 
288
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
 
289
          <li class="nav-item nav-item-2"><a href="strings.html" >7. String Services</a> &raquo;</li> 
 
290
      </ul>
 
291
    </div>  
 
292
    <div class="footer">
 
293
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
 
294
    <br />
 
295
    The Python Software Foundation is a non-profit corporation.
 
296
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
297
    <br />
 
298
    Last updated on Jan 23, 2016.
 
299
    <a href="../bugs.html">Found a bug</a>?
 
300
    <br />
 
301
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
302
    </div>
 
303
 
 
304
  </body>
 
305
</html>
 
 
b'\\ No newline at end of file'