Commit 689aa6d3 authored by Alexander Belopolsky's avatar Alexander Belopolsky

Merged revisions 86526 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86526 | alexander.belopolsky | 2010-11-18 13:50:13 -0500 (Thu, 18 Nov 2010) | 1 line

  Issue 7828: Fixed chr() and ord() documentation for wide characters
........
parent dae5b84f
...@@ -105,11 +105,15 @@ are always available. They are listed here in alphabetical order. ...@@ -105,11 +105,15 @@ are always available. They are listed here in alphabetical order.
.. function:: chr(i) .. function:: chr(i)
Return the string of one character whose Unicode codepoint is the integer Return the string representing a character whose Unicode codepoint is the integer
*i*. For example, ``chr(97)`` returns the string ``'a'``. This is the *i*. For example, ``chr(97)`` returns the string ``'a'``. This is the
inverse of :func:`ord`. The valid range for the argument depends how Python inverse of :func:`ord`. The valid range for the argument is from 0 through
was configured -- it may be either UCS2 [0..0xFFFF] or UCS4 [0..0x10FFFF]. 1,114,111 (0x10FFFF in base 16). :exc:`ValueError` will be raised if *i* is
:exc:`ValueError` will be raised if *i* is outside that range. outside that range.
Note that on narrow Unicode builds, the result is a string of
length two for *i* greater than 65,535 (0xFFFF in hexadecimal).
.. function:: classmethod(function) .. function:: classmethod(function)
...@@ -811,14 +815,14 @@ are always available. They are listed here in alphabetical order. ...@@ -811,14 +815,14 @@ are always available. They are listed here in alphabetical order.
.. XXX works for bytes too, but should it? .. XXX works for bytes too, but should it?
.. function:: ord(c) .. function:: ord(c)
Given a string of length one, return an integer representing the Unicode code Given a string representing one Uncicode character, return an integer
point of the character. For example, ``ord('a')`` returns the integer ``97`` representing the Unicode code
point of that character. For example, ``ord('a')`` returns the integer ``97``
and ``ord('\u2020')`` returns ``8224``. This is the inverse of :func:`chr`. and ``ord('\u2020')`` returns ``8224``. This is the inverse of :func:`chr`.
If the argument length is not one, a :exc:`TypeError` will be raised. (If On wide Unicode builds, if the argument length is not one, a
Python was built with UCS2 Unicode, then the character's code point must be :exc:`TypeError` will be raised. On narrow Unicode builds, strings
in the range [0..65535] inclusive; otherwise the string length is two!) of length two are accepted when they form a UTF-16 surrogate pair.
.. function:: pow(x, y[, z]) .. function:: pow(x, y[, z])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment