View Single Post
Old Feb 9th, 2007, 6:27 PM   #2
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
First of all read up on unicode at:
http://www.python.org/peps/pep-0263.html

Also here is a small code sample I wrote a while ago that might help you in your quest:
# Python supports Unicode strings whose individual characters 
# are 16 bits. The full Unicode set contains Cyrillic, Chinese,
# Japanese and other language characters. They probably wouldn't
# show up on a typical US computer.  You can play with characters
# up to hexadecimal FF though.
# A Unicode string literal is preceded with a 'u'

# not much happens here ...
a = u'How are you?'
print a
# result is  How are you?

# here I used the unicode \uxxxx where xxxx is a four digit
# hexadecimal number to put in two typical Spanish characters
# 00bf = ¿  and  00f3 = ó  that are not on my US keyboard
a = u'\u00bfC\u00f3mo es usted?'
print a
# result is ¿Cómo es usted?

# these are really in the ASCII set, so we could have done it this way
a = u'\xbfC\xf3mo es usted?'
print a
Just a note of caution, not all editors handle unicode properly!
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote