[Python-Dev] [patch #100889] a smaller unicode name database
M.-A. Lemburg
mal@lemburg.com
Sat, 15 Jul 2000 20:09:49 +0200
Fredrik Lundh wrote:
>
> > my unicode database compression project has resulted in its first
> > patch:
> >
> > https://sourceforge.net/patch/index.php?func=detailpatch&patch_id=100899&group_id=5470
>
> two additional comments:
>
> first, the patch was too large for sourceforge (>512000 bytes), so
> I've uploaded it to the secret effbot site instead:
>
> http://w1.132.telia.com/~u13208596/uninames-patch.txt
>
> second, the uninames module provides two public Python functions:
I'd name this: unicodenames (we shouldn't be afraid of long
module names ;-).
> getname(code) returns the character name corresponding to
> the given character code, or None if the name is not known.
>
> getcode(name) returns the character code for the given character
> name. again, it returns None if the code is not known.
>
> Q: should I raise exceptions instead of returning None?
Yes...
getname() with an unkown code means that an unassigned
code is being requested: this is a ValueError.
getcode(name) should raise a ValueError exception too, since the
requested name may be unsupported by Python's version of the Unicode lib
(vers. 3.0).
BTW, did you make the lookups case insensitive ? (Would be
useful, IMHO.)
> Q: what other functions would be useful? getallnames()? anything
> else?
Perhaps a dictionary like interface written on top of
the above two APIs (in Python, of course).
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/