This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: chr() and ord() documentation for wide characters
Type: Stage: resolved
Components: Documentation, Unicode Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: amaury.forgeotdarc, belopolsky, djc, docs@python, ezio.melotti, georg.brandl, nudgenudge, vstinner
Priority: normal Keywords: patch

Created on 2010-02-01 04:51 by nudgenudge, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7828.diff belopolsky, 2010-11-18 17:51
Messages (3)
msg98648 - (view) Author: (nudgenudge) Date: 2010-02-01 04:51
The documentation of chr() and ord() fails to mention that on narrow Unicode builds, chr(n) will return a surrogate pair (hence a 2-character string) for n>=65536 and that ord(s) will accept a 2-character string if it's a surrogate pair.

Example:
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> list(chr(123456))
['\ud838', '\ude40']
>>> len(chr(123456))
2
>>> ord(chr(123456))
123456
>>>
msg121482 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-11-18 18:10
Looks good to me, except for a 'stings' near the end of the patch.
msg121486 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-11-18 18:55
Committed in r86526 (3.2) and r86527 (3.1).
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52076
2010-11-18 18:55:38belopolskysetstatus: open -> closed
resolution: fixed
messages: + msg121486

stage: patch review -> resolved
2010-11-18 18:10:17amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg121482
2010-11-18 17:51:40belopolskysetfiles: + issue7828.diff
keywords: + patch
stage: needs patch -> patch review
2010-11-17 23:53:38belopolskysetassignee: docs@python -> belopolsky

nosy: + belopolsky
2010-10-21 00:42:58vstinnersetnosy: georg.brandl, vstinner, djc, ezio.melotti, nudgenudge, docs@python
components: + Unicode
2010-08-03 16:59:22pitrousetassignee: georg.brandl -> docs@python
versions: - Python 2.6, Python 2.7
nosy: + vstinner, docs@python
2010-08-03 14:14:58djcsetnosy: + djc
2010-02-14 18:38:25ezio.melottisetpriority: normal
nosy: + ezio.melotti
versions: + Python 2.6, Python 2.7

stage: needs patch
2010-02-01 04:51:56nudgenudgecreate