views:

71

answers:

2

I'm using python for S60. I want to use string in hebrew, to represent them on the GUI and to send them in SMS message. It seems that the PythonScriptShell don't accept such expressions, for example:

u"אבגדה"

what can I do? thanks

development of situation: I added the line:

# -*- coding: utf-8 -*-

as the first line in the source file and in notepad++ I selected: Encoding>>Convert to utf8.

now, the GUI appears in Hebrew but when I selected an option the selection value cannot be compared to a string in Hebrew in the code (probably) and there is no response.

On PythonScriptShell appears the warning:

Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal.

Help me, please.

A: 

convert your words to unicode characters using unichr eg unichr(1507) for char ף

refer to the decimal values in this table: http://www.ssec.wisc.edu/~tomw/java/unicode.html#x0590

Christian Smorra
I didn't understand. I have a string in hebrew, what to do next?
Day_Dreamer
lookup each character and print them with unichr()
Christian Smorra
I don't think that makes a huge difference compared to a Unicode literal like `u"אבגדה"`: Both result in Python Unicode strings. The problem must be on the S60 side.
Philipp
@Philipp: You have any idea how to solve it?
Day_Dreamer
+1  A: 

I just tested this in both bluetooth and on-phone consoles with PyS60 2.0, and non-ASCII unicode was handled w/out exceptions.

If you have that string in the file rather than passing it in the console, error is caused by lack of encoding specification in the file.

Add # -*- coding: utf-8 -*- as first line there.

Daniel Kluev
I added this row exactly and got the error message:"UnicodeDecodeError: 'utf8' codec can't decode bytesin position 0-2: invalid data.
Day_Dreamer
@Day_Dreaner ー then, obviously, you need to save your file in utf-8, or edit the header to match w/e encoding your editor uses.
Daniel Kluev
how do I save a file in utf-8? I'm using npp.
Day_Dreamer