1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>7.10. stringprep — Internet String Preparation — Python 2.7.11 documentation</title>
11
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
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>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="fpformat.html" title="7.11. fpformat — Floating point conversions"
55
accesskey="N">next</a> |</li>
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> »</li>
63
<span class="version_switcher_placeholder">2.7.11</span>
64
<a href="../index.html">Documentation</a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
68
<li class="nav-item nav-item-2"><a href="strings.html" accesskey="U">7. String Services</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
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> — 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>
82
<p>When identifying things (such as host names) in the internet, it is often
83
necessary to compare such identifications for “equality”. 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
“printable” 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 “preparing” 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 “characteristic function”, 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>
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>
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>
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>
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>
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>
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
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>
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>
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
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>
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>
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>
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>
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
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
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>
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
“R” or “AL”).</p>
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
“L”).</p>
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> — Unicode Database</a></p>
239
<p class="topless"><a href="fpformat.html"
240
title="next chapter">7.11. <code class="docutils literal"><span class="pre">fpformat</span></code> — Floating point conversions</a></p>
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>
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" />
256
<p class="searchtip" style="font-size: 90%">
257
Enter search terms or a module, class or function name.
260
<script type="text/javascript">$('#searchbox').show(0);</script>
263
<div class="clearer"></div>
265
<div class="related" role="navigation" aria-label="related navigation">
268
<li class="right" style="margin-right: 10px">
269
<a href="../genindex.html" title="General Index"
272
<a href="../py-modindex.html" title="Python Module Index"
275
<a href="fpformat.html" title="7.11. fpformat — Floating point conversions"
278
<a href="unicodedata.html" title="7.9. unicodedata — Unicode Database"
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> »</li>
284
<span class="version_switcher_placeholder">2.7.11</span>
285
<a href="../index.html">Documentation</a> »
288
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
289
<li class="nav-item nav-item-2"><a href="strings.html" >7. String Services</a> »</li>
293
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
295
The Python Software Foundation is a non-profit corporation.
296
<a href="https://www.python.org/psf/donations/">Please donate.</a>
298
Last updated on Jan 23, 2016.
299
<a href="../bugs.html">Found a bug</a>?
301
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'