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.

Day_Dreamer
  • 3,311
  • 7
  • 34
  • 61

3 Answers3

1

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
  • 11,025
  • 2
  • 36
  • 36
0

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
  • 1,756
  • 11
  • 13
  • I didn't understand. I have a string in hebrew, what to do next? – Day_Dreamer Aug 01 '10 at 03:41
  • 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 Aug 01 '10 at 13:50
0

Add up ru = lambda txt: str(txt).decode('utf-8','ignore')

And add the function before each text use ru("אבגדה")

mordi
  • 41
  • 1
  • 7