korsygfhrtzangaiide
Elepffwdsff
/
usr
/
share
/
doc
/
python-docs-2.7.5
/
html
/
library
/
Upload FileeE
HOME
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>15.13. curses.ascii — Utilities for ASCII characters — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="15. Generic Operating System Services" href="allos.html" /> <link rel="next" title="15.14. curses.panel — A panel stack extension for curses" href="curses.panel.html" /> <link rel="prev" title="15.11. curses — Terminal handling for character-cell displays" href="curses.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="curses.panel.html" title="15.14. curses.panel — A panel stack extension for curses" accesskey="N">next</a> |</li> <li class="right" > <a href="curses.html" title="15.11. curses — Terminal handling for character-cell displays" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="allos.html" accesskey="U">15. Generic Operating System Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-curses.ascii"> <span id="curses-ascii-utilities-for-ascii-characters"></span><h1>15.13. <a class="reference internal" href="#module-curses.ascii" title="curses.ascii: Constants and set-membership functions for ASCII characters."><tt class="xref py py-mod docutils literal"><span class="pre">curses.ascii</span></tt></a> — Utilities for ASCII characters<a class="headerlink" href="#module-curses.ascii" title="Permalink to this headline">¶</a></h1> <p class="versionadded"> <span class="versionmodified">New in version 1.6.</span></p> <p>The <a class="reference internal" href="#module-curses.ascii" title="curses.ascii: Constants and set-membership functions for ASCII characters."><tt class="xref py py-mod docutils literal"><span class="pre">curses.ascii</span></tt></a> module supplies name constants for ASCII characters and functions to test membership in various ASCII character classes. The constants supplied are names for control characters as follows:</p> <table border="1" class="docutils"> <colgroup> <col width="23%" /> <col width="77%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Name</th> <th class="head">Meaning</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">NUL</span></tt></td> <td> </td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">SOH</span></tt></td> <td>Start of heading, console interrupt</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">STX</span></tt></td> <td>Start of text</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">ETX</span></tt></td> <td>End of text</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">EOT</span></tt></td> <td>End of transmission</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">ENQ</span></tt></td> <td>Enquiry, goes with <tt class="xref py py-const docutils literal"><span class="pre">ACK</span></tt> flow control</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">ACK</span></tt></td> <td>Acknowledgement</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">BEL</span></tt></td> <td>Bell</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">BS</span></tt></td> <td>Backspace</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">TAB</span></tt></td> <td>Tab</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">HT</span></tt></td> <td>Alias for <tt class="xref py py-const docutils literal"><span class="pre">TAB</span></tt>: “Horizontal tab”</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">LF</span></tt></td> <td>Line feed</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">NL</span></tt></td> <td>Alias for <tt class="xref py py-const docutils literal"><span class="pre">LF</span></tt>: “New line”</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">VT</span></tt></td> <td>Vertical tab</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">FF</span></tt></td> <td>Form feed</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">CR</span></tt></td> <td>Carriage return</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">SO</span></tt></td> <td>Shift-out, begin alternate character set</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">SI</span></tt></td> <td>Shift-in, resume default character set</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">DLE</span></tt></td> <td>Data-link escape</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">DC1</span></tt></td> <td>XON, for flow control</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">DC2</span></tt></td> <td>Device control 2, block-mode flow control</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">DC3</span></tt></td> <td>XOFF, for flow control</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">DC4</span></tt></td> <td>Device control 4</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">NAK</span></tt></td> <td>Negative acknowledgement</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">SYN</span></tt></td> <td>Synchronous idle</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">ETB</span></tt></td> <td>End transmission block</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">CAN</span></tt></td> <td>Cancel</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">EM</span></tt></td> <td>End of medium</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">SUB</span></tt></td> <td>Substitute</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">ESC</span></tt></td> <td>Escape</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">FS</span></tt></td> <td>File separator</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">GS</span></tt></td> <td>Group separator</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">RS</span></tt></td> <td>Record separator, block-mode terminator</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">US</span></tt></td> <td>Unit separator</td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">SP</span></tt></td> <td>Space</td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">DEL</span></tt></td> <td>Delete</td> </tr> </tbody> </table> <p>Note that many of these have little practical significance in modern usage. The mnemonics derive from teleprinter conventions that predate digital computers.</p> <p>The module supplies the following functions, patterned on those in the standard C library:</p> <dl class="function"> <dt id="curses.ascii.isalnum"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isalnum</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isalnum" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII alphanumeric character; it is equivalent to <tt class="docutils literal"><span class="pre">isalpha(c)</span> <span class="pre">or</span> <span class="pre">isdigit(c)</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isalpha"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isalpha</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isalpha" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII alphabetic character; it is equivalent to <tt class="docutils literal"><span class="pre">isupper(c)</span> <span class="pre">or</span> <span class="pre">islower(c)</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isascii"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isascii</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isascii" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for a character value that fits in the 7-bit ASCII set.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isblank"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isblank</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isblank" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII whitespace character.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.iscntrl"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">iscntrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.iscntrl" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII control character (in the range 0x00 to 0x1f).</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isdigit"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isdigit</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isdigit" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII decimal digit, <tt class="docutils literal"><span class="pre">'0'</span></tt> through <tt class="docutils literal"><span class="pre">'9'</span></tt>. This is equivalent to <tt class="docutils literal"><span class="pre">c</span> <span class="pre">in</span> <span class="pre">string.digits</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isgraph"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isgraph</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isgraph" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for ASCII any printable character except space.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.islower"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">islower</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.islower" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII lower-case character.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isprint"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isprint</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isprint" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for any ASCII printable character including space.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.ispunct"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">ispunct</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ispunct" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for any printable ASCII character which is not a space or an alphanumeric character.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isspace"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isspace</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isspace" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for ASCII white-space characters; space, line feed, carriage return, form feed, horizontal tab, vertical tab.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isupper"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isupper</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isupper" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII uppercase letter.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isxdigit"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isxdigit</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isxdigit" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII hexadecimal digit. This is equivalent to <tt class="docutils literal"><span class="pre">c</span> <span class="pre">in</span> <span class="pre">string.hexdigits</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.isctrl"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">isctrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isctrl" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for an ASCII control character (ordinal values 0 to 31).</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.ismeta"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">ismeta</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ismeta" title="Permalink to this definition">¶</a></dt> <dd><p>Checks for a non-ASCII character (ordinal values 0x80 and above).</p> </dd></dl> <p>These functions accept either integers or strings; when the argument is a string, it is first converted using the built-in function <a class="reference internal" href="functions.html#ord" title="ord"><tt class="xref py py-func docutils literal"><span class="pre">ord()</span></tt></a>.</p> <p>Note that all these functions check ordinal bit values derived from the first character of the string you pass in; they do not actually know anything about the host machine’s character encoding. For functions that know about the character encoding (and handle internationalization properly) see the <a class="reference internal" href="string.html#module-string" title="string: Common string operations."><tt class="xref py py-mod docutils literal"><span class="pre">string</span></tt></a> module.</p> <p>The following two functions take either a single-character string or integer byte value; they return a value of the same type.</p> <dl class="function"> <dt id="curses.ascii.ascii"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">ascii</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ascii" title="Permalink to this definition">¶</a></dt> <dd><p>Return the ASCII value corresponding to the low 7 bits of <em>c</em>.</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.ctrl"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">ctrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ctrl" title="Permalink to this definition">¶</a></dt> <dd><p>Return the control character corresponding to the given character (the character bit value is bitwise-anded with 0x1f).</p> </dd></dl> <dl class="function"> <dt id="curses.ascii.alt"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">alt</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.alt" title="Permalink to this definition">¶</a></dt> <dd><p>Return the 8-bit character corresponding to the given ASCII character (the character bit value is bitwise-ored with 0x80).</p> </dd></dl> <p>The following function takes either a single-character string or integer value; it returns a string.</p> <dl class="function"> <dt id="curses.ascii.unctrl"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">unctrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.unctrl" title="Permalink to this definition">¶</a></dt> <dd><p>Return a string representation of the ASCII character <em>c</em>. If <em>c</em> is printable, this string is the character itself. If the character is a control character (0x00-0x1f) the string consists of a caret (<tt class="docutils literal"><span class="pre">'^'</span></tt>) followed by the corresponding uppercase letter. If the character is an ASCII delete (0x7f) the string is <tt class="docutils literal"><span class="pre">'^?'</span></tt>. If the character has its meta bit (0x80) set, the meta bit is stripped, the preceding rules applied, and <tt class="docutils literal"><span class="pre">'!'</span></tt> prepended to the result.</p> </dd></dl> <dl class="data"> <dt id="curses.ascii.controlnames"> <tt class="descclassname">curses.ascii.</tt><tt class="descname">controlnames</tt><a class="headerlink" href="#curses.ascii.controlnames" title="Permalink to this definition">¶</a></dt> <dd><p>A 33-element string array that contains the ASCII mnemonics for the thirty-two ASCII control characters from 0 (NUL) to 0x1f (US), in order, plus the mnemonic <tt class="docutils literal"><span class="pre">SP</span></tt> for the space character.</p> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="curses.html" title="previous chapter">15.11. <tt class="docutils literal"><span class="pre">curses</span></tt> — Terminal handling for character-cell displays</a></p> <h4>Next topic</h4> <p class="topless"><a href="curses.panel.html" title="next chapter">15.14. <tt class="docutils literal"><span class="pre">curses.panel</span></tt> — A panel stack extension for curses</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/curses.ascii.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="curses.panel.html" title="15.14. curses.panel — A panel stack extension for curses" >next</a> |</li> <li class="right" > <a href="curses.html" title="15.11. curses — Terminal handling for character-cell displays" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="allos.html" >15. Generic Operating System Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>