Re: Get alternative char name with unicodedata.name() if no formal one defined

2010-10-14 Thread John Machin
On Oct 14, 7:25 pm, Dirk Wallenstein  wrote:
> Hi,
> I'd like to get control char names for the first 32 codepoints, but they
> apparently only have an alias and no official name. Is there a way to
> get the alternative character name (alias) in Python?
>

AFAIK there is no programatically-available list of those names. Try
something like:

name = unicodedata.name(x, some_default) if x > u"\x1f" else ("NULL",
etc etc, "UNIT SEPARATOR")[ord(x)]

or similarly with a prepared dict:

C0_CONTROL_NAMES = {
u"\x00": "NULL",
# etc
u"\x1f": "UNIT SEPARATOR",
}

name = unicodedata.name(x, some_default) if x > u"\x1f" else
C0_CONTROL_NAMES[x]
-- 
http://mail.python.org/mailman/listinfo/python-list


Get alternative char name with unicodedata.name() if no formal one defined

2010-10-14 Thread Dirk Wallenstein
Hi,
I'd like to get control char names for the first 32 codepoints, but they
apparently only have an alias and no official name. Is there a way to
get the alternative character name (alias) in Python?

-- 
Greetings,
Dirk
-- 
http://mail.python.org/mailman/listinfo/python-list