[Python-bugs-list] [ python-Bugs-593581 ] u'%c' % large value: broken result

noreply@sourceforge.net noreply@sourceforge.net
Sat, 10 Aug 2002 21:35:01 -0700


Bugs item #593581, was opened at 2002-08-11 00:35
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=593581&group_id=5470

Category: Unicode
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Guido van Rossum (gvanrossum)
Assigned to: M.-A. Lemburg (lemburg)
Summary: u'%c' % large value: broken result

Initial Comment:
The unicode implementation of '%c' % x does no range
checking on x, and out-of-range values can cause weird
effects. You might want to implement the same range
checking as 8-bit strings use, restricting x to values
in range(256). Or you might want to implement
unichr(x), restricting x to values in range(0xffff).
But right now it's a mess:

>>> u'%c' % 100
u'd'
>>> u'%c' % 300
u','
>>> u'%c' % 900
u'\uff84'
>>> u'%c' % -900
u'|'
>>> 


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=593581&group_id=5470