[Python-Dev] Internationalization Toolkit
M.-A. Lemburg
mal@lemburg.com
Wed, 10 Nov 1999 13:44:39 +0100
Greg Stein wrote:
>
> On Wed, 10 Nov 1999, M.-A. Lemburg wrote:
> > Tim Peters wrote:
> > > BTW, is ord(unicode_char) defined? And as what? And does ord have an
> > > inverse in the Unicode world? Both seem essential.
> >
> > Good points.
> >
> > How about
> >
> > uniord(u[:1]) --> Unicode ordinal number (32-bit)
> >
> > unichr(i) --> Unicode object for character i (provided it is 32-bit);
> > ValueError otherwise
>
> Why new functions? Why not extend the definition of ord() and chr()?
>
> In terms of backwards compatibility, the only issue could possibly be that
> people relied on chr(x) to throw an error when x>=256. They certainly
> couldn't pass a Unicode object to ord(), so that function can safely be
> extended to accept a Unicode object and return a larger integer.
Because unichr() will always have to return Unicode objects. You don't
want chr(i) to return Unicode for i>255 and strings for i<256.
OTOH, ord() could probably be extended to also work on Unicode objects.
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 51 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/