summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Funicodedata.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/python~3.12/library%2Funicodedata.html')
-rw-r--r--devdocs/python~3.12/library%2Funicodedata.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Funicodedata.html b/devdocs/python~3.12/library%2Funicodedata.html
new file mode 100644
index 00000000..777aa615
--- /dev/null
+++ b/devdocs/python~3.12/library%2Funicodedata.html
@@ -0,0 +1,70 @@
+ <span id="unicodedata-unicode-database"></span><h1>unicodedata — Unicode Database</h1> <p>This module provides access to the Unicode Character Database (UCD) which defines character properties for all Unicode characters. The data contained in this database is compiled from the <a class="reference external" href="https://www.unicode.org/Public/15.0.0/ucd">UCD version 15.0.0</a>.</p> <p>The module uses the same names and symbols as defined by Unicode Standard Annex #44, <a class="reference external" href="https://www.unicode.org/reports/tr44/">“Unicode Character Database”</a>. It defines the following functions:</p> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.lookup">
+<code>unicodedata.lookup(name)</code> </dt> <dd>
+<p>Look up character by name. If a character with the given name is found, return the corresponding character. If not found, <a class="reference internal" href="exceptions#KeyError" title="KeyError"><code>KeyError</code></a> is raised.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span>Support for name aliases <a class="footnote-reference brackets" href="#id3" id="id1">1</a> and named sequences <a class="footnote-reference brackets" href="#id4" id="id2">2</a> has been added.</p> </div> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.name">
+<code>unicodedata.name(chr[, default])</code> </dt> <dd>
+<p>Returns the name assigned to the character <em>chr</em> as a string. If no name is defined, <em>default</em> is returned, or, if not given, <a class="reference internal" href="exceptions#ValueError" title="ValueError"><code>ValueError</code></a> is raised.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.decimal">
+<code>unicodedata.decimal(chr[, default])</code> </dt> <dd>
+<p>Returns the decimal value assigned to the character <em>chr</em> as integer. If no such value is defined, <em>default</em> is returned, or, if not given, <a class="reference internal" href="exceptions#ValueError" title="ValueError"><code>ValueError</code></a> is raised.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.digit">
+<code>unicodedata.digit(chr[, default])</code> </dt> <dd>
+<p>Returns the digit value assigned to the character <em>chr</em> as integer. If no such value is defined, <em>default</em> is returned, or, if not given, <a class="reference internal" href="exceptions#ValueError" title="ValueError"><code>ValueError</code></a> is raised.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.numeric">
+<code>unicodedata.numeric(chr[, default])</code> </dt> <dd>
+<p>Returns the numeric value assigned to the character <em>chr</em> as float. If no such value is defined, <em>default</em> is returned, or, if not given, <a class="reference internal" href="exceptions#ValueError" title="ValueError"><code>ValueError</code></a> is raised.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.category">
+<code>unicodedata.category(chr)</code> </dt> <dd>
+<p>Returns the general category assigned to the character <em>chr</em> as string.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.bidirectional">
+<code>unicodedata.bidirectional(chr)</code> </dt> <dd>
+<p>Returns the bidirectional class assigned to the character <em>chr</em> as string. If no such value is defined, an empty string is returned.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.combining">
+<code>unicodedata.combining(chr)</code> </dt> <dd>
+<p>Returns the canonical combining class assigned to the character <em>chr</em> as integer. Returns <code>0</code> if no combining class is defined.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.east_asian_width">
+<code>unicodedata.east_asian_width(chr)</code> </dt> <dd>
+<p>Returns the east asian width assigned to the character <em>chr</em> as string.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.mirrored">
+<code>unicodedata.mirrored(chr)</code> </dt> <dd>
+<p>Returns the mirrored property assigned to the character <em>chr</em> as integer. Returns <code>1</code> if the character has been identified as a “mirrored” character in bidirectional text, <code>0</code> otherwise.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.decomposition">
+<code>unicodedata.decomposition(chr)</code> </dt> <dd>
+<p>Returns the character decomposition mapping assigned to the character <em>chr</em> as string. An empty string is returned in case no such mapping is defined.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.normalize">
+<code>unicodedata.normalize(form, unistr)</code> </dt> <dd>
+<p>Return the normal form <em>form</em> for the Unicode string <em>unistr</em>. Valid values for <em>form</em> are ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’.</p> <p>The Unicode standard defines various normalization forms of a Unicode string, based on the definition of canonical equivalence and compatibility equivalence. In Unicode, several characters can be expressed in various way. For example, the character U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) can also be expressed as the sequence U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA).</p> <p>For each character, there are two normal forms: normal form C and normal form D. Normal form D (NFD) is also known as canonical decomposition, and translates each character into its decomposed form. Normal form C (NFC) first applies a canonical decomposition, then composes pre-combined characters again.</p> <p>In addition to these two forms, there are two additional normal forms based on compatibility equivalence. In Unicode, certain characters are supported which normally would be unified with other characters. For example, U+2160 (ROMAN NUMERAL ONE) is really the same thing as U+0049 (LATIN CAPITAL LETTER I). However, it is supported in Unicode for compatibility with existing character sets (e.g. gb2312).</p> <p>The normal form KD (NFKD) will apply the compatibility decomposition, i.e. replace all compatibility characters with their equivalents. The normal form KC (NFKC) first applies the compatibility decomposition, followed by the canonical composition.</p> <p>Even if two unicode strings are normalized and look the same to a human reader, if one has combining characters and the other doesn’t, they may not compare equal.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="unicodedata.is_normalized">
+<code>unicodedata.is_normalized(form, unistr)</code> </dt> <dd>
+<p>Return whether the Unicode string <em>unistr</em> is in the normal form <em>form</em>. Valid values for <em>form</em> are ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.8.</span></p> </div> </dd>
+</dl> <p>In addition, the module exposes the following constant:</p> <dl class="py data"> <dt class="sig sig-object py" id="unicodedata.unidata_version">
+<code>unicodedata.unidata_version</code> </dt> <dd>
+<p>The version of the Unicode database used in this module.</p> </dd>
+</dl> <dl class="py data"> <dt class="sig sig-object py" id="unicodedata.ucd_3_2_0">
+<code>unicodedata.ucd_3_2_0</code> </dt> <dd>
+<p>This is an object that has the same methods as the entire module, but uses the Unicode database version 3.2 instead, for applications that require this specific version of the Unicode database (such as IDNA).</p> </dd>
+</dl> <p>Examples:</p> <pre data-language="python">&gt;&gt;&gt; import unicodedata
+&gt;&gt;&gt; unicodedata.lookup('LEFT CURLY BRACKET')
+'{'
+&gt;&gt;&gt; unicodedata.name('/')
+'SOLIDUS'
+&gt;&gt;&gt; unicodedata.decimal('9')
+9
+&gt;&gt;&gt; unicodedata.decimal('a')
+Traceback (most recent call last):
+ File "&lt;stdin&gt;", line 1, in &lt;module&gt;
+ValueError: not a decimal
+&gt;&gt;&gt; unicodedata.category('A') # 'L'etter, 'u'ppercase
+'Lu'
+&gt;&gt;&gt; unicodedata.bidirectional('\u0660') # 'A'rabic, 'N'umber
+'AN'
+</pre> <h4 class="rubric">Footnotes</h4> <dl class="footnote brackets"> <dt class="label" id="id3">
+<code>1</code> </dt> <dd>
+<p><a class="reference external" href="https://www.unicode.org/Public/15.0.0/ucd/NameAliases.txt">https://www.unicode.org/Public/15.0.0/ucd/NameAliases.txt</a></p> </dd> <dt class="label" id="id4">
+<code>2</code> </dt> <dd>
+<p><a class="reference external" href="https://www.unicode.org/Public/15.0.0/ucd/NamedSequences.txt">https://www.unicode.org/Public/15.0.0/ucd/NamedSequences.txt</a></p> </dd> </dl> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/library/unicodedata.html" class="_attribution-link">https://docs.python.org/3.12/library/unicodedata.html</a>
+ </p>
+</div>