Inverse of Python's unicodedata.name? -
there built-in method unicodedata.name given unicode character return human readable name, e.g.:
unicodedata.name(chr(0x2704)) == "white scissors"
is there out there provide inverse? i'm looking like:
unicodedata.name("white scissors") == chr(0x2704) or 0x2704
i loop on possible values, build map, seems inefficient , hoping exists. using python 3 open 3-only solutions.
you're looking unicodedata.lookup
:
in [5]: unicodedata.lookup("white scissors") out[5]: '✄'
this returns character, use ord
integer ordinal:
in [7]: ord(unicodedata.lookup("white scissors")) out[7]: 9988 # hex(9988) 0x2704
Comments
Post a Comment