added "getcode" and "getname" methods to the ucnhash module (they're

probably more useful for the test code than for any applications, but
one never knows...)
This commit is contained in:
Fredrik Lundh 2001-01-19 11:00:42 +00:00
parent d5d2cd149f
commit ee865c64da
2 changed files with 75 additions and 13 deletions

View file

@ -37,6 +37,23 @@ s = u"\N{LATIN CAPITAL LETTER T}" \
u"\N{LATIN SMALL LETTER P}" \
u"\N{FULL STOP}"
verify(s == u"The rEd fOx ate the sheep.", s)
import ucnhash
# minimal sanity check
for char in "SPAM":
name = "LATIN SMALL LETTER %s" % char
code = ucnhash.getcode(name)
verify(ucnhash.getname(code) == name)
# loop over all characters in the database
for code in range(65536):
try:
name = ucnhash.getname(code)
verify(ucnhash.getcode(name) == code)
except ValueError:
pass
print "done."
# misc. symbol testing