Help for unicode

N

Noixe

Hello,

I'm italian and i not speak a good english. My problem is this:

Why this istruction:

print u"\u00" + str(41)

generate an error and this:

print u"\u0041" no?


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.

Thanks
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Noixe said:
Hello,

I'm italian and i not speak a good english. My problem is this:

Why this istruction:

print u"\u00" + str(41)

generate an error and this:

print u"\u0041" no?

That's because Unicode literals (\uxxxx) are interpreted at compile
time, not at runtime.
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.

I don't know which symbol this is in Unicode, maybe somebody else can?

-- Gerhard
 
I

Irmen de Jong

Noixe said:
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:
u'\u2205'

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

Noixe

"Irmen de Jong" <[email protected]> ha scritto:

If I write:

print u'\u2205'

I have this error: UnicodeError: ASCII encoding error: ordinal not in
range(128)


Why? I must include some module?
 
M

Martin v. =?iso-8859-15?q?L=F6wis?=

Noixe said:
print u'\u2205'

I have this error: UnicodeError: ASCII encoding error: ordinal not in
range(128)


Why? I must include some module?

No. Just don't print it:
u'\u2205'

The character U+2205 is EMPTY SET; your terminal is not capable of
displaying that symbol.

Regards,
Martin
 
I

Irmen de Jong

Noixe said:
Ah... and not exist one solution?

Change your output to something that *does* support displaying
U+2205, such as a HTML document that you then read with a
decent web browser.

Or you could use 'LATIN SMALL LETTER O WITH STROKE' instead,
U+00f8 (u'\xf8'). It looks very similar to the EMPTY SET symbol,
and because it is just a normal letter instead of a mathematical
symbol, it is much more likely to be supported by your terminal.

--Irmen
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Noixe said:
Ah... and not exist one solution?

What kind of output would you like to get? I'm sure it can be arranged,
if your computer hardware is good enough. However, you have to tell us
what solution you want.

Regards,
Martin
 
D

David Eppstein

"Noixe said:
If I write:

print u'\u2205'

I have this error: UnicodeError: ASCII encoding error: ordinal not in
range(128)


Why? I must include some module?

You have to specify which encoding you want to print it in.
E.g.
Of course this will only work if the output stream you print to is set
up to use that encoding...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,464
Latest member
Bobbylenly

Latest Threads

Top