Help for unicode

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sat Nov 8 17:35:33 EST 2003


Noixe wrote:
> Why this istruction:
> 
> print u"\u00" + str(41)
> 
> generate an error and this:
> 
> print u"\u0041"   no?

because they are doing very different things.
The first is first evaluating u"\u00" and only
if that succeeds (but it doesn't) add the string
"41" at the end.

The second is evaluating the unicode escape
sequence \u0041 that is part of the string.

You cannot combine strings like that to form
arbitrary unicode escape sequences. Try this instead;

some_variable=0x0041

print unichr(some_variable)


> Can I use all 65536 symbols of unicode in my program? For example, I need to
> use the mathematic symbol of void set. It has a 0198 number in a table of
> symbol that there is in Windows.

No problem to use all unicode symbols.

But I don't think the empty set symbols is Unicode code point U+0198:

 >>> import unicodedata
 >>> unicodedata.name(u'\u0198')
'LATIN CAPITAL LETTER K WITH HOOK'
 >>> unicodedata.lookup("EMPTY SET")
u'\u2205'

So I think you should use U+2205 instead?
--Irmen





More information about the Python-list mailing list