[Python-Dev] Internationalization Toolkit

Greg Stein gstein@lyra.org
Thu, 11 Nov 1999 02:50:56 -0800 (PST)


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.

Cheers,
-g

--
Greg Stein, http://www.lyra.org/