Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / module-unicodedata.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-stringprep.html" />
<link rel="prev" href="module-codecs.html" />
<link rel="parent" href="strings.html" />
<link rel="next" href="module-stringprep.html" />
<meta name='aesop' content='information' />
<title>4.10 unicodedata -- Unicode Database</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="4.9.3 encodings.idna "
href="module-encodings.idna.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4. String Services"
href="strings.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="4.11 stringprep "
href="module-stringprep.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-encodings.idna.html">4.9.3 encodings.idna </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="strings.html">4. String Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-stringprep.html">4.11 stringprep </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0061000000000000000000">
4.10 <tt class="module">unicodedata</tt> --
Unicode Database</A>
</H1>
<P>
<A NAME="module-unicodedata"></A>
<P>
<a id='l2h-1037' xml:id='l2h-1037'></a>
<a id='l2h-1023' xml:id='l2h-1023'></a>
<P>
This module provides access to the Unicode Character Database which
defines character properties for all Unicode characters. The data in
this database is based on the <span class="file">UnicodeData.txt</span> file version
3.2.0 which is publically available from <a class="url" href="ftp://ftp.unicode.org/">ftp://ftp.unicode.org/</a>.
<P>
The module uses the same names and symbols as defined by the
UnicodeData File Format 3.2.0 (see
<a class="url" href="http://www.unicode.org/Public/UNIDATA/UnicodeData.html">http://www.unicode.org/Public/UNIDATA/UnicodeData.html</a>). It
defines the following functions:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1024' xml:id='l2h-1024' class="function">lookup</tt></b>(</nobr></td>
<td><var>name</var>)</td></tr></table></dt>
<dd>
Look up character by name. If a character with the
given name is found, return the corresponding Unicode
character. If not found, <tt class="exception">KeyError</tt> is raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1025' xml:id='l2h-1025' class="function">name</tt></b>(</nobr></td>
<td><var>unichr</var><big>[</big><var>, default</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Returns the name assigned to the Unicode character
<var>unichr</var> as a string. If no name is defined,
<var>default</var> is returned, or, if not given,
<tt class="exception">ValueError</tt> is raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1026' xml:id='l2h-1026' class="function">decimal</tt></b>(</nobr></td>
<td><var>unichr</var><big>[</big><var>, default</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Returns the decimal value assigned to the Unicode character
<var>unichr</var> as integer. If no such value is defined,
<var>default</var> is returned, or, if not given,
<tt class="exception">ValueError</tt> is raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1027' xml:id='l2h-1027' class="function">digit</tt></b>(</nobr></td>
<td><var>unichr</var><big>[</big><var>, default</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Returns the digit value assigned to the Unicode character
<var>unichr</var> as integer. If no such value is defined,
<var>default</var> is returned, or, if not given,
<tt class="exception">ValueError</tt> is raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1028' xml:id='l2h-1028' class="function">numeric</tt></b>(</nobr></td>
<td><var>unichr</var><big>[</big><var>, default</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Returns the numeric value assigned to the Unicode character
<var>unichr</var> as float. If no such value is defined, <var>default</var> is
returned, or, if not given, <tt class="exception">ValueError</tt> is raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1029' xml:id='l2h-1029' class="function">category</tt></b>(</nobr></td>
<td><var>unichr</var>)</td></tr></table></dt>
<dd>
Returns the general category assigned to the Unicode character
<var>unichr</var> as string.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1030' xml:id='l2h-1030' class="function">bidirectional</tt></b>(</nobr></td>
<td><var>unichr</var>)</td></tr></table></dt>
<dd>
Returns the bidirectional category assigned to the Unicode character
<var>unichr</var> as string. If no such value is defined, an empty string
is returned.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1031' xml:id='l2h-1031' class="function">combining</tt></b>(</nobr></td>
<td><var>unichr</var>)</td></tr></table></dt>
<dd>
Returns the canonical combining class assigned to the Unicode
character <var>unichr</var> as integer. Returns <code>0</code> if no combining
class is defined.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1032' xml:id='l2h-1032' class="function">east_asian_width</tt></b>(</nobr></td>
<td><var>unichr</var>)</td></tr></table></dt>
<dd>
Returns the east asian width assigned to the Unicode character
<var>unichr</var> as string.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1033' xml:id='l2h-1033' class="function">mirrored</tt></b>(</nobr></td>
<td><var>unichr</var>)</td></tr></table></dt>
<dd>
Returns the mirrored property assigned to the Unicode character
<var>unichr</var> as integer. Returns <code>1</code> if the character has been
identified as a ``mirrored'' character in bidirectional text,
<code>0</code> otherwise.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1034' xml:id='l2h-1034' class="function">decomposition</tt></b>(</nobr></td>
<td><var>unichr</var>)</td></tr></table></dt>
<dd>
Returns the character decomposition mapping assigned to the Unicode
character <var>unichr</var> as string. An empty string is returned in case
no such mapping is defined.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1035' xml:id='l2h-1035' class="function">normalize</tt></b>(</nobr></td>
<td><var>form, unistr</var>)</td></tr></table></dt>
<dd>
<P>
Return the normal form <var>form</var> for the Unicode string <var>unistr</var>.
Valid values for <var>form</var> are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
<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>
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>
In addition to these two forms, there 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>
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>
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
In addition, the module exposes the following constant:
<P>
<dl><dt><b><tt id='l2h-1036' xml:id='l2h-1036'>unidata_version</tt></b></dt>
<dd>
The version of the Unicode database used in this module.
<P>
<span class="versionnote">New in version 2.3.</span>
</dd></dl>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="4.9.3 encodings.idna "
href="module-encodings.idna.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4. String Services"
href="strings.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="4.11 stringprep "
href="module-stringprep.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-encodings.idna.html">4.9.3 encodings.idna </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="strings.html">4. String Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-stringprep.html">4.11 stringprep </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>