473,327 Members | 1,979 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,327 software developers and data experts.

Can someone provide some help with unicode please.

11
I'm using python 2.6.5 on windows vista and for some reason I'm having trouble trying to get python to recognize unicode input.( A friend tried the exact same code on linux and it works fine)
Expand|Select|Wrap|Line Numbers
  1. >>> verb=u"とぶ"
  2. >>> verb[-1]==u"ぶ"
  3. False
  4. >>> 

Does anyone have any idea what's happening here?
Isn't that supposed to yield True and not False?

(I also tried single quotes, but no luck)

Thank you.
May 29 '10 #1
2 1487
dwblas
626 Expert 512MB
Since this is being done within the Python interpreter, it uses whatever encoding is set for the system. Obviously the default encoding can not handle these (16 bit?) characters. A Python program file can contain coding. Something like
# -*- coding: latin-1 -*-
You can print the default encoding with
sys.getdefaultencoding()
Beyond that, it depends on which version of Python you and your friend are using. A Google for "python unicode" will link to millions of explanations and examples.
May 29 '10 #2
2inshix
11
thank you dwblas,
I took me a while but I was able to find the way to handle
japanese unicode.
Inside a program, of course,
We need these lines at the top of the page: (This what you were talking about in your reply)
Expand|Select|Wrap|Line Numbers
  1. # -*- coding: cp932 -*-
  2.  
  3. import codecs
  4.  
Once we have that, we need to add the character "u" before every unicode string like thus:
Expand|Select|Wrap|Line Numbers
  1. u'日本語'
  2.  
And problem solve.
Thank you, again and happy new year!
Jan 5 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: turlupin | last post by:
hi! i have a problem. i dont understand... help me please http://www.animals-superstars.com/photo-109260.html tank you patate069
2
by: xpcer | last post by:
Halo everybody, can you help me, please. Can you tell me: 1. How many databases can we create in mysql (using Windows Operating Systems) 2. How many tables can we create in every database? 3....
7
by: Mickyd1561 | last post by:
Hey everyone I'm new to this groups thing and thought maybe someone can help me. My problem is that I can't view specific images on only one website. www.baseballu.net is my baseball team's...
2
by: hassruby | last post by:
Can someone pls help me with some validation that im having a few technical problems with in my program. First of all, I will explain to you a little about what my program is suppose to do. It...
0
by: karizmatrix22 | last post by:
I using Microsoft ASP.NET web matrix program to create asp website..i would like to link a image to the another page.for example..when the user click on the image it should take user to the next...
1
by: Andrea Belmonte - www.andreabelmonte.com | last post by:
Hi everybody, I'm developing a C# .Net (1.1 Framework) Windows Application, and I need to encrypt, using PKCS#1 v 1.5 padding, a string using an RSA 1024 bits public key, situated in a X.509 .cer...
3
by: james121285 | last post by:
I have written a program that will take the max and min of 10 set values. I have to now change my program to allow for these inputs to be entered in by another document, and print the values into...
0
by: bacterium | last post by:
Help me ,Please!!! I tried to use the DB2 database,but I got an error:SQL116N because of BACKUP PENDING,cannot connect or active"PBZXJK(DataBase Name)",SQLConnectAttr failured. Thanks!
2
by: Dalton | last post by:
This is all kind of in another language to, I mean I understand most of the words in relation to programming, but my field of work/study is IT. Anyways, on to the problem. I am working on my 5th...
0
by: sara | last post by:
Hi - I posted this earlier and didn't get any response. Hopefully someone can help?? I have a table keeping track of employees' jobs in a location. So, Store #1 Manager #353, AsstMgr #556...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.