Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
unicodedata.html660 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="unicodedata — Unicode Database" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/unicodedata.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="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 UCD versi..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_unicodedata_484da18c.png" />15<meta property="og:image:alt" content="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 UCD versi..." />16<meta name="description" content="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 UCD versi..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>unicodedata — Unicode Database &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="stringprep — Internet String Preparation" href="stringprep.html" />43    <link rel="prev" title="textwrap — Text wrapping and filling" href="textwrap.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/unicodedata.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h4>Previous topic</h4>106    <p class="topless"><a href="textwrap.html"107                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">textwrap</span></code> — Text wrapping and filling</a></p>108  </div>109  <div>110    <h4>Next topic</h4>111    <p class="topless"><a href="stringprep.html"112                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringprep</span></code> — Internet String Preparation</a></p>113  </div>114  <script>115    document.addEventListener('DOMContentLoaded', () => {116        const title = document.querySelector('meta[property="og:title"]').content;117        const elements = document.querySelectorAll('.improvepage');118        const pageurl = window.location.href.split('?')[0];119        elements.forEach(element => {120            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));121            url.searchParams.set('pagetitle', title);122            url.searchParams.set('pageurl', pageurl);123            url.searchParams.set('pagesource', "library/unicodedata.rst");124            element.href = url.toString();125        });126    });127  </script>128  <div role="note" aria-label="source link">129    <h3>This page</h3>130    <ul class="this-page-menu">131      <li><a href="../bugs.html">Report a bug</a></li>132      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>133      <li>134        <a href="https://github.com/python/cpython/blob/main/Doc/library/unicodedata.rst?plain=1"135            rel="nofollow">Show source136        </a>137      </li>138      139    </ul>140  </div>141        </nav>142    </div>143</div>144 145  146    <div class="related" role="navigation" aria-label="Related">147      <h3>Navigation</h3>148      <ul>149        <li class="right" style="margin-right: 10px">150          <a href="../genindex.html" title="General Index"151             accesskey="I">index</a></li>152        <li class="right" >153          <a href="../py-modindex.html" title="Python Module Index"154             >modules</a> |</li>155        <li class="right" >156          <a href="stringprep.html" title="stringprep — Internet String Preparation"157             accesskey="N">next</a> |</li>158        <li class="right" >159          <a href="textwrap.html" title="textwrap — Text wrapping and filling"160             accesskey="P">previous</a> |</li>161 162          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>163          <li><a href="https://www.python.org/">Python</a> &#187;</li>164          <li class="switchers">165            <div class="language_switcher_placeholder"></div>166            <div class="version_switcher_placeholder"></div>167          </li>168          <li>169              170          </li>171    <li id="cpython-language-and-version">172      <a href="../index.html">3.15.0a6 Documentation</a> &#187;173    </li>174 175          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>176          <li class="nav-item nav-item-2"><a href="text.html" accesskey="U">Text Processing Services</a> &#187;</li>177        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">unicodedata</span></code> — Unicode Database</a></li>178                <li class="right">179                    180 181    <div class="inline-search" role="search">182        <form class="inline-search" action="../search.html" method="get">183          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">184          <input type="submit" value="Go">185        </form>186    </div>187                     |188                </li>189            <li class="right">190<label class="theme-selector-label">191    Theme192    <select class="theme-selector" oninput="activateTheme(this.value)">193        <option value="auto" selected>Auto</option>194        <option value="light">Light</option>195        <option value="dark">Dark</option>196    </select>197</label> |</li>198            199      </ul>200    </div>    201 202    <div class="document">203      <div class="documentwrapper">204        <div class="bodywrapper">205          <div class="body" role="main">206            207  <section id="module-unicodedata">208<span id="unicodedata-unicode-database"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">unicodedata</span></code> — Unicode Database<a class="headerlink" href="#module-unicodedata" title="Link to this heading">¶</a></h1>209<hr class="docutils" id="index-0" />210<p>This module provides access to the Unicode Character Database (UCD) which211defines character properties for all Unicode characters. The data contained in212this database is compiled from the <a class="reference external" href="https://www.unicode.org/Public/17.0.0/ucd">UCD version 17.0.0</a>.</p>213<p>The module uses the same names and symbols as defined by Unicode214Standard Annex #44, <a class="reference external" href="https://www.unicode.org/reports/tr44/">“Unicode Character Database”</a>.  It defines the215following functions:</p>216<div class="admonition seealso">217<p class="admonition-title">See also</p>218<p>The <a class="reference internal" href="../howto/unicode.html#unicode-howto"><span class="std std-ref">Unicode HOWTO</span></a> for more information about Unicode and how to use219this module.</p>220</div>221<dl class="py function">222<dt class="sig sig-object py" id="unicodedata.lookup">223<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">lookup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.lookup" title="Link to this definition">¶</a></dt>224<dd><p>Look up character by name.  If a character with the given name is found, return225the corresponding character.  If not found, <a class="reference internal" href="exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> is raised.226For example:</p>227<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s1">&#39;LEFT CURLY BRACKET&#39;</span><span class="p">)</span>228<span class="go">&#39;{&#39;</span>229</pre></div>230</div>231<p>The characters returned by this function are the same as those produced by232<code class="docutils literal notranslate"><span class="pre">\N</span></code> escape sequence in string literals. For example:</p>233<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s1">&#39;MIDDLE DOT&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;</span><span class="se">\N{MIDDLE DOT}</span><span class="s1">&#39;</span>234<span class="go">True</span>235</pre></div>236</div>237<div class="versionchanged">238<p><span class="versionmodified changed">Changed in version 3.3: </span>Support for name aliases <a class="footnote-reference brackets" href="#id4" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> and named sequences <a class="footnote-reference brackets" href="#id5" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> has been added.</p>239</div>240</dd></dl>241 242<dl class="py function">243<dt class="sig sig-object py" id="unicodedata.name">244<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">name</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.name" title="Link to this definition">¶</a></dt>245<dd><p>Returns the name assigned to the character <em>chr</em> as a string. If no246name is defined, <em>default</em> is returned, or, if not given, <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is247raised. For example:</p>248<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">name</span><span class="p">(</span><span class="s1">&#39;½&#39;</span><span class="p">)</span>249<span class="go">&#39;VULGAR FRACTION ONE HALF&#39;</span>250<span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">name</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\uFFFF</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;fallback&#39;</span><span class="p">)</span>251<span class="go">&#39;fallback&#39;</span>252</pre></div>253</div>254</dd></dl>255 256<dl class="py function">257<dt class="sig sig-object py" id="unicodedata.decimal">258<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">decimal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.decimal" title="Link to this definition">¶</a></dt>259<dd><p>Returns the decimal value assigned to the character <em>chr</em> as integer.260If no such value is defined, <em>default</em> is returned, or, if not given,261<a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised. For example:</p>262<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">decimal</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\N{ARABIC-INDIC DIGIT NINE}</span><span class="s1">&#39;</span><span class="p">)</span>263<span class="go">9</span>264<span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">decimal</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\N{SUPERSCRIPT NINE}</span><span class="s1">&#39;</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>265<span class="go">-1</span>266</pre></div>267</div>268</dd></dl>269 270<dl class="py function">271<dt class="sig sig-object py" id="unicodedata.digit">272<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">digit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.digit" title="Link to this definition">¶</a></dt>273<dd><p>Returns the digit value assigned to the character <em>chr</em> as integer.274If no such value is defined, <em>default</em> is returned, or, if not given,275<a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised:</p>276<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">digit</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\N{SUPERSCRIPT NINE}</span><span class="s1">&#39;</span><span class="p">)</span>277<span class="go">9</span>278</pre></div>279</div>280</dd></dl>281 282<dl class="py function">283<dt class="sig sig-object py" id="unicodedata.numeric">284<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">numeric</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.numeric" title="Link to this definition">¶</a></dt>285<dd><p>Returns the numeric value assigned to the character <em>chr</em> as float.286If no such value is defined, <em>default</em> is returned, or, if not given,287<a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised:</p>288<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">numeric</span><span class="p">(</span><span class="s1">&#39;½&#39;</span><span class="p">)</span>289<span class="go">0.5</span>290</pre></div>291</div>292</dd></dl>293 294<dl class="py function">295<dt class="sig sig-object py" id="unicodedata.category">296<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">category</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.category" title="Link to this definition">¶</a></dt>297<dd><p>Returns the general category assigned to the character <em>chr</em> as298string. General category names consist of two letters.299See the <a class="reference external" href="https://www.unicode.org/reports/tr44/#General_Category_Values">General Category Values section of the Unicode Character300Database documentation</a>301for a list of category codes. For example:</p>302<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">category</span><span class="p">(</span><span class="s1">&#39;A&#39;</span><span class="p">)</span>  <span class="c1"># &#39;L&#39;etter, &#39;u&#39;ppercase</span>303<span class="go">&#39;Lu&#39;</span>304</pre></div>305</div>306</dd></dl>307 308<dl class="py function">309<dt class="sig sig-object py" id="unicodedata.bidirectional">310<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">bidirectional</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.bidirectional" title="Link to this definition">¶</a></dt>311<dd><p>Returns the bidirectional class assigned to the character <em>chr</em> as312string. If no such value is defined, an empty string is returned.313See the <a class="reference external" href="https://www.unicode.org/reports/tr44/#Bidi_Class_Values">Bidirectional Class Values section of the Unicode Character314Database</a>315documentation for a list of bidirectional codes. For example:</p>316<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">bidirectional</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\N{ARABIC-INDIC DIGIT SEVEN}</span><span class="s1">&#39;</span><span class="p">)</span> <span class="c1"># &#39;A&#39;rabic, &#39;N&#39;umber</span>317<span class="go">&#39;AN&#39;</span>318</pre></div>319</div>320</dd></dl>321 322<dl class="py function">323<dt class="sig sig-object py" id="unicodedata.combining">324<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">combining</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.combining" title="Link to this definition">¶</a></dt>325<dd><p>Returns the canonical combining class assigned to the character <em>chr</em>326as integer. Returns <code class="docutils literal notranslate"><span class="pre">0</span></code> if no combining class is defined.327See the <a class="reference external" href="https://www.unicode.org/reports/tr44/#Canonical_Combining_Class_Values">Canonical Combining Class Values section of the Unicode Character328Database</a>329for more information.</p>330</dd></dl>331 332<dl class="py function">333<dt class="sig sig-object py" id="unicodedata.east_asian_width">334<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">east_asian_width</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.east_asian_width" title="Link to this definition">¶</a></dt>335<dd><p>Returns the east asian width assigned to the character <em>chr</em> as336string. For a list of widths and or more information, see the337<a class="reference external" href="https://www.unicode.org/reports/tr11/">Unicode Standard Annex #11</a>.</p>338</dd></dl>339 340<dl class="py function">341<dt class="sig sig-object py" id="unicodedata.block">342<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.block" title="Link to this definition">¶</a></dt>343<dd><p>Returns the <a class="reference external" href="https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G64189">block</a>344assigned to the character <em>chr</em>. For example:</p>345<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">block</span><span class="p">(</span><span class="s1">&#39;S&#39;</span><span class="p">)</span>346<span class="go">&#39;Basic Latin&#39;</span>347</pre></div>348</div>349<div class="versionadded">350<p><span class="versionmodified added">Added in version 3.15.0a6 (unreleased).</span></p>351</div>352</dd></dl>353 354<dl class="py function">355<dt class="sig sig-object py" id="unicodedata.mirrored">356<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">mirrored</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.mirrored" title="Link to this definition">¶</a></dt>357<dd><p>Returns the mirrored property assigned to the character <em>chr</em> as358integer. Returns <code class="docutils literal notranslate"><span class="pre">1</span></code> if the character has been identified as a “mirrored”359character in bidirectional text, <code class="docutils literal notranslate"><span class="pre">0</span></code> otherwise. For example:</p>360<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">mirrored</span><span class="p">(</span><span class="s1">&#39;&gt;&#39;</span><span class="p">)</span>361<span class="go">1</span>362</pre></div>363</div>364</dd></dl>365 366<dl class="py function">367<dt class="sig sig-object py" id="unicodedata.isxidstart">368<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">isxidstart</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.isxidstart" title="Link to this definition">¶</a></dt>369<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <em>chr</em> is a valid identifier start per the370<a class="reference external" href="https://www.unicode.org/reports/tr31/">Unicode Standard Annex #31</a>,371that is, it has the <code class="docutils literal notranslate"><span class="pre">XID_Start</span></code> property. Return <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.372For example:</p>373<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">isxidstart</span><span class="p">(</span><span class="s1">&#39;S&#39;</span><span class="p">)</span>374<span class="go">True</span>375<span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">isxidstart</span><span class="p">(</span><span class="s1">&#39;0&#39;</span><span class="p">)</span>376<span class="go">False</span>377</pre></div>378</div>379<div class="versionadded">380<p><span class="versionmodified added">Added in version 3.15.</span></p>381</div>382</dd></dl>383 384<dl class="py function">385<dt class="sig sig-object py" id="unicodedata.isxidcontinue">386<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">isxidcontinue</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.isxidcontinue" title="Link to this definition">¶</a></dt>387<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <em>chr</em> is a valid identifier character per the388<a class="reference external" href="https://www.unicode.org/reports/tr31/">Unicode Standard Annex #31</a>,389that is, it has the <code class="docutils literal notranslate"><span class="pre">XID_Continue</span></code> property. Return <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.390For example:</p>391<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">isxidcontinue</span><span class="p">(</span><span class="s1">&#39;S&#39;</span><span class="p">)</span>392<span class="go">True</span>393<span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">isxidcontinue</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span>394<span class="go">False</span>395</pre></div>396</div>397<div class="versionadded">398<p><span class="versionmodified added">Added in version 3.15.</span></p>399</div>400</dd></dl>401 402<dl class="py function">403<dt class="sig sig-object py" id="unicodedata.decomposition">404<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">decomposition</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.decomposition" title="Link to this definition">¶</a></dt>405<dd><p>Returns the character decomposition mapping assigned to the character406<em>chr</em> as string. An empty string is returned in case no such mapping is407defined. For example:</p>408<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">unicodedata</span><span class="o">.</span><span class="n">decomposition</span><span class="p">(</span><span class="s1">&#39;Ã&#39;</span><span class="p">)</span>409<span class="go">&#39;0041 0303&#39;</span>410</pre></div>411</div>412</dd></dl>413 414<dl class="py function">415<dt class="sig sig-object py" id="unicodedata.grapheme_cluster_break">416<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">grapheme_cluster_break</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.grapheme_cluster_break" title="Link to this definition">¶</a></dt>417<dd><p>Returns the Grapheme_Cluster_Break property assigned to the character.</p>418<div class="versionadded">419<p><span class="versionmodified added">Added in version 3.15.</span></p>420</div>421</dd></dl>422 423<dl class="py function">424<dt class="sig sig-object py" id="unicodedata.indic_conjunct_break">425<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">indic_conjunct_break</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.indic_conjunct_break" title="Link to this definition">¶</a></dt>426<dd><p>Returns the Indic_Conjunct_Break property assigned to the character.</p>427<div class="versionadded">428<p><span class="versionmodified added">Added in version 3.15.</span></p>429</div>430</dd></dl>431 432<dl class="py function">433<dt class="sig sig-object py" id="unicodedata.extended_pictographic">434<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">extended_pictographic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.extended_pictographic" title="Link to this definition">¶</a></dt>435<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the character has the Extended_Pictographic property,436<code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>437<div class="versionadded">438<p><span class="versionmodified added">Added in version 3.15.</span></p>439</div>440</dd></dl>441 442<dl class="py function">443<dt class="sig sig-object py" id="unicodedata.normalize">444<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">normalize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">form</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unistr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.normalize" title="Link to this definition">¶</a></dt>445<dd><p>Return the normal form <em>form</em> for the Unicode string <em>unistr</em>. Valid values for446<em>form</em> are ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’.</p>447<p>The Unicode standard defines various normalization forms of a Unicode string,448based on the definition of canonical equivalence and compatibility equivalence.449In Unicode, several characters can be expressed in various way. For example, the450character U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) can also be expressed as451the sequence U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA).</p>452<p>For each character, there are two normal forms: normal form C and normal form D.453Normal form D (NFD) is also known as canonical decomposition, and translates454each character into its decomposed form. Normal form C (NFC) first applies a455canonical decomposition, then composes pre-combined characters again.</p>456<p>In addition to these two forms, there are two additional normal forms based on457compatibility equivalence. In Unicode, certain characters are supported which458normally would be unified with other characters. For example, U+2160 (ROMAN459NUMERAL ONE) is really the same thing as U+0049 (LATIN CAPITAL LETTER I).460However, it is supported in Unicode for compatibility with existing character461sets (for example, gb2312).</p>462<p>The normal form KD (NFKD) will apply the compatibility decomposition, that is,463replace all compatibility characters with their equivalents. The normal form KC464(NFKC) first applies the compatibility decomposition, followed by the canonical465composition.</p>466<p>Even if two unicode strings are normalized and look the same to467a human reader, if one has combining characters and the other468doesn’t, they may not compare equal.</p>469</dd></dl>470 471<dl class="py function">472<dt class="sig sig-object py" id="unicodedata.is_normalized">473<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">is_normalized</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">form</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unistr</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.is_normalized" title="Link to this definition">¶</a></dt>474<dd><p>Return whether the Unicode string <em>unistr</em> is in the normal form <em>form</em>. Valid475values for <em>form</em> are ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’.</p>476<div class="versionadded">477<p><span class="versionmodified added">Added in version 3.8.</span></p>478</div>479</dd></dl>480 481<dl class="py function">482<dt class="sig sig-object py" id="unicodedata.iter_graphemes">483<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">iter_graphemes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">unistr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">start</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">sys.maxsize</span></span></em>, <em class="sig-param"><span class="positional-only-separator o"><abbr title="Positional-only parameter separator (PEP 570)"><span class="pre">/</span></abbr></span></em><span class="sig-paren">)</span><a class="headerlink" href="#unicodedata.iter_graphemes" title="Link to this definition">¶</a></dt>484<dd><p>Returns an iterator to iterate over grapheme clusters.485With optional <em>start</em>, iteration begins at that position.486With optional <em>end</em>, iteration stops at that position.</p>487<p>Converting an emitted item to string returns a substring corresponding to488the grapheme cluster.489Its <code class="docutils literal notranslate"><span class="pre">start</span></code> and <code class="docutils literal notranslate"><span class="pre">end</span></code> attributes denote the start and end of490the grapheme cluster.</p>491<p>It uses extended grapheme cluster rules defined by Unicode492Standard Annex #29, <a class="reference external" href="https://www.unicode.org/reports/tr29/">“Unicode Text Segmentation”</a>.</p>493<div class="versionadded">494<p><span class="versionmodified added">Added in version 3.15.</span></p>495</div>496</dd></dl>497 498<p>In addition, the module exposes the following constant:</p>499<dl class="py data">500<dt class="sig sig-object py" id="unicodedata.unidata_version">501<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">unidata_version</span></span><a class="headerlink" href="#unicodedata.unidata_version" title="Link to this definition">¶</a></dt>502<dd><p>The version of the Unicode database used in this module.</p>503</dd></dl>504 505<dl class="py data">506<dt class="sig sig-object py" id="unicodedata.ucd_3_2_0">507<span class="sig-prename descclassname"><span class="pre">unicodedata.</span></span><span class="sig-name descname"><span class="pre">ucd_3_2_0</span></span><a class="headerlink" href="#unicodedata.ucd_3_2_0" title="Link to this definition">¶</a></dt>508<dd><p>This is an object that has most of the methods of the entire module, but uses the509Unicode database version 3.2 instead, for applications that require this510specific version of the Unicode database (such as IDNA).</p>511</dd></dl>512 513<p class="rubric">Footnotes</p>514<aside class="footnote-list brackets">515<aside class="footnote brackets" id="id4" role="doc-footnote">516<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span>517<p><a class="reference external" href="https://www.unicode.org/Public/17.0.0/ucd/NameAliases.txt">https://www.unicode.org/Public/17.0.0/ucd/NameAliases.txt</a></p>518</aside>519<aside class="footnote brackets" id="id5" role="doc-footnote">520<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id2">2</a><span class="fn-bracket">]</span></span>521<p><a class="reference external" href="https://www.unicode.org/Public/17.0.0/ucd/NamedSequences.txt">https://www.unicode.org/Public/17.0.0/ucd/NamedSequences.txt</a></p>522</aside>523</aside>524</section>525 526 527            <div class="clearer"></div>528          </div>529        </div>530      </div>531      <div class="sphinxsidebar" role="navigation" aria-label="Main">532        <div class="sphinxsidebarwrapper">533  <div>534    <h4>Previous topic</h4>535    <p class="topless"><a href="textwrap.html"536                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">textwrap</span></code> — Text wrapping and filling</a></p>537  </div>538  <div>539    <h4>Next topic</h4>540    <p class="topless"><a href="stringprep.html"541                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">stringprep</span></code> — Internet String Preparation</a></p>542  </div>543  <script>544    document.addEventListener('DOMContentLoaded', () => {545        const title = document.querySelector('meta[property="og:title"]').content;546        const elements = document.querySelectorAll('.improvepage');547        const pageurl = window.location.href.split('?')[0];548        elements.forEach(element => {549            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));550            url.searchParams.set('pagetitle', title);551            url.searchParams.set('pageurl', pageurl);552            url.searchParams.set('pagesource', "library/unicodedata.rst");553            element.href = url.toString();554        });555    });556  </script>557  <div role="note" aria-label="source link">558    <h3>This page</h3>559    <ul class="this-page-menu">560      <li><a href="../bugs.html">Report a bug</a></li>561      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>562      <li>563        <a href="https://github.com/python/cpython/blob/main/Doc/library/unicodedata.rst?plain=1"564            rel="nofollow">Show source565        </a>566      </li>567      568    </ul>569  </div>570        </div>571<div id="sidebarbutton" title="Collapse sidebar">572<span>«</span>573</div>574 575      </div>576      <div class="clearer"></div>577    </div>  578    <div class="related" role="navigation" aria-label="Related">579      <h3>Navigation</h3>580      <ul>581        <li class="right" style="margin-right: 10px">582          <a href="../genindex.html" title="General Index"583             >index</a></li>584        <li class="right" >585          <a href="../py-modindex.html" title="Python Module Index"586             >modules</a> |</li>587        <li class="right" >588          <a href="stringprep.html" title="stringprep — Internet String Preparation"589             >next</a> |</li>590        <li class="right" >591          <a href="textwrap.html" title="textwrap — Text wrapping and filling"592             >previous</a> |</li>593 594          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>595          <li><a href="https://www.python.org/">Python</a> &#187;</li>596          <li class="switchers">597            <div class="language_switcher_placeholder"></div>598            <div class="version_switcher_placeholder"></div>599          </li>600          <li>601              602          </li>603    <li id="cpython-language-and-version">604      <a href="../index.html">3.15.0a6 Documentation</a> &#187;605    </li>606 607          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>608          <li class="nav-item nav-item-2"><a href="text.html" >Text Processing Services</a> &#187;</li>609        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">unicodedata</span></code> — Unicode Database</a></li>610                <li class="right">611                    612 613    <div class="inline-search" role="search">614        <form class="inline-search" action="../search.html" method="get">615          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">616          <input type="submit" value="Go">617        </form>618    </div>619                     |620                </li>621            <li class="right">622<label class="theme-selector-label">623    Theme624    <select class="theme-selector" oninput="activateTheme(this.value)">625        <option value="auto" selected>Auto</option>626        <option value="light">Light</option>627        <option value="dark">Dark</option>628    </select>629</label> |</li>630            631      </ul>632    </div>  633    <div class="footer">634    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.635    <br>636    This page is licensed under the Python Software Foundation License Version 2.637    <br>638    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.639    <br>640    641      See <a href="/license.html">History and License</a> for more information.<br>642    643    644    <br>645 646    The Python Software Foundation is a non-profit corporation.647<a href="https://www.python.org/psf/donations/">Please donate.</a>648<br>649    <br>650      Last updated on Mar 10, 2026 (08:58 UTC).651    652      <a href="/bugs.html">Found a bug</a>?653    654    <br>655 656    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.657    </div>658 659  </body>660</html>