开发者

strings in hebrew in python for s60

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 (开发者_JAVA百科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.


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.


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


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜