473,373 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,373 software developers and data experts.

Help for unicode

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
--
Noixe
Jul 18 '05 #1
10 2722
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

Jul 18 '05 #2
Thanks!
Jul 18 '05 #3
"Irmen de Jong" <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> 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?

--
Noixe
Jul 18 '05 #4
Noixe wrote:
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
Jul 18 '05 #5
"Noixe" <No**********@hotmail.com> writes:
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:
x=u'\u2205'
x

u'\u2205'

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

Regards,
Martin

Jul 18 '05 #6
"Martin v. Löwis" <ma****@v.loewis.de> ha scritto:
The character U+2205 is EMPTY SET; your terminal is not capable of
displaying that symbol.


Ah... and not exist one solution?

--
Noixe
Jul 18 '05 #7
Noixe wrote:
The character U+2205 is EMPTY SET; your terminal is not capable of
displaying that symbol.

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

Jul 18 '05 #8
Noixe wrote:
The character U+2205 is EMPTY SET; your terminal is not capable of
displaying that symbol.

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

Jul 18 '05 #9
"Martin v. Löwis" <ma****@v.loewis.de> ha scritto:

No problem. It's no so important.

--
Noixe
Jul 18 '05 #10
In article <2p**********************@twister1.libero.it>,
"Noixe" <No**********@hotmail.com> wrote:
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.
print u'\u2205'.encode('utf8')


Of course this will only work if the output stream you print to is set
up to use that encoding...

--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
Jul 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bernd Preusing | last post by:
Hi, today I (Python beginner) ran into a problem:^ I have a JPG file which contains some comment as unicode. After reading in the string with s=file.read(70) from file offest 4 I get a...
40
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. ...
0
by: Chris | last post by:
Hi, I found this code to send print direct to printer. It works perfect. Imports System Imports System.Text Imports System.Runtime.InteropServices <StructLayout(LayoutKind.Sequential)> _...
17
by: VM | last post by:
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times (datatable row count), copy cthe data of each row -3 fields- to a struct, and send the strct to...
1
by: aarthy | last post by:
Hi, I have a problem in the display of the ASP screen actually i am retrieving and displaying the data from a database when the view button is hit.The contents for display is so long so i want...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
40
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
4
by: Robin Haswell | last post by:
Okay I'm getting really frustrated with Python's Unicode handling, I'm trying everything I can think of an I can't escape Unicode(En|De)codeError no matter what I try. Could someone explain to...
12
by: manstey | last post by:
I am writing a program to translate a list of ascii letters into a different language that requires unicode encoding. This is what I have done so far: 1. I have # -*- coding: UTF-8 -*- as my...
7
by: Rymfax | last post by:
I would really appreciate it if someone could help me figure out what I'm doing wrong trying to PInvoke SetupDiEnumDriverInfo. All the other PInvokes i've done up to this point work fine. Whenver...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.