You Are Here:

Community: Developer Discussion Boards

#1 Old about ui encoding use chinese language - 2006-04-23, 15:57

Join Date: Apr 2006
Posts: 4
icej
Offline
Registered User
I use chinese language in "appuifw.query(u"你好","text")",but it is not nomail.
How i can use in it?
THANKS!
Reply With Quote

#2 Old Question Re: about ui encoding use chinese language - 2007-02-28, 04:46

Join Date: Feb 2007
Posts: 43
jfml
Offline
Registered User
I got this question also, anyone can help me?

Maybe most of friends on the board can not see chinese chars : "你好" yet, so they can not understand what I ask?
Reply With Quote

#3 Old Re: about ui encoding use chinese language - 2007-02-28, 10:11

Join Date: May 2004
Posts: 524
Location: Tampere, Finland
jethro.fn's Avatar
jethro.fn
Offline
Forum Nokia Champion
Quote:
Originally Posted by jfml
Maybe most of friends on the board can not see chinese chars : "你好" yet, so they can not understand what I ask?
I see them just fine...

PyS60 is Python v2.2. Python v2.2 only supports ISO 8859-1 ("ISO Latin-1") characters in Unicode string literals. For example, this works when the file is saved in ISO 8859-1 ("ö" is ISO-8859-1 character number 246 or 0xf6 in hex):

Code:
import appuifw
appuifw.note(u"Böö!", "info")
Now, the characters you gave as an example ("你好") cannot be represented in ISO 8859-1. After all, ISO 8859-1 is just an 8-bit character set, containing only 191 printable characters.

Unicode characters outside the eight bit ISO 8859-1 range must be represented as Unicode escapes in string literals. There are several posts about this in the forum:

http://discussion.forum.nokia.com/fo...d.php?t=101549
http://discussion.forum.nokia.com/fo...ad.php?t=83710


So, to print "你好", you must use u"\u4f60\u597d" in your program.
Reply With Quote

#4 Old Talking Re: about ui encoding use chinese language - 2007-03-01, 05:53

Join Date: Feb 2007
Posts: 43
jfml
Offline
Registered User
Quote:
Originally Posted by jethro.fn
I see them just fine...

PyS60 is Python v2.2. Python v2.2 only supports ISO 8859-1 ("ISO Latin-1") characters in Unicode string literals. For example, this works when the file is saved in ISO 8859-1 ("ö" is ISO-8859-1 character number 246 or 0xf6 in hex):

Code:
import appuifw
appuifw.note(u"Böö!", "info")
Now, the characters you gave as an example ("你好") cannot be represented in ISO 8859-1. After all, ISO 8859-1 is just an 8-bit character set, containing only 191 printable characters.

Unicode characters outside the eight bit ISO 8859-1 range must be represented as Unicode escapes in string literals. There are several posts about this in the forum:

http://discussion.forum.nokia.com/fo...d.php?t=101549
http://discussion.forum.nokia.com/fo...ad.php?t=83710


So, to print "你好", you must use u"\u4f60\u597d" in your program.
Hi, jethro.fn:
I have a low-level question : how can I get u"\u4f60\u597d" from "你好" in python? -_-|||
Thanks.
Reply With Quote

#5 Old Re: about ui encoding use chinese language - 2007-03-01, 13:28

Join Date: May 2004
Posts: 524
Location: Tampere, Finland
jethro.fn's Avatar
jethro.fn
Offline
Forum Nokia Champion
Quote:
Originally Posted by jfml
How can I get u"\u4f60\u597d" from "你好" in python?
I don't quite understand what you ask. I think you mean one of these two questions:

a) How was I able to determine which Unicode escapes represent the characters "你" and "好"?

or

b) Can you include Chinese characters as-is in the Python source code and if yes, how?


I'll answer both questions.

a) I copied the two chinese characters to a Unicode-aware text editor and saved to a file using UTF-8 encoding. Then, I read the file in a Python program on my PC, decoded the UTF-8 encoding and printed the resulting Unicode escapes, like this:

Code:
print repr(file("test.txt").read().decode("utf8"))
b) Officially, PyS60 (Python v2.2) does not support chinese characters (or any other characters outside ISO 8859-1 repertoire) in Unicode literals. However, as UTF-8 encoding uses bytes compatible with ISO 8859-1, you can save Python files in UTF-8 and then decode the UTF-8 encoding manually:

Code:
import appuifw
appuifw.note("你好".decode("utf-8"), "info")
Important things to note:
  • This is an ugly hack. It will not work with Python v2.3 and later, unless an encoding of ISO 8859-1 is explicitly declared (see PEP 0263 for more info). Python v2.3 and later support UTF-8 encoding directly, making this hack obsolete.
  • "你好" must not be a Unicode string, i.e. u"你好" will not work!
  • Configure your editor to save UTF-8 files. No other encoding will work. Disable UTF-8 BOM (Byte Order Mark) as it may prevent PyS60 from loading the file (not tested).
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Chinese character encoding chandlersee Other Programming Discussion 关于其他编程技术的讨论 3 2004-11-11 14:04
How do I get Chinese language into my 6230? fssia General Discussion 2 2004-10-02 03:58
7250i chinese language? apollo333 Web Technologies and Multimedia Content- Web 技术和多媒体内容 1 2004-02-02 04:29
About S60 Chinese MIDP SDK Chinese language support zhaolikang Mobile Java General 0 2004-01-09 03:38
Chinese file encoding. fmhunter Other Programming Discussion 关于其他编程技术的讨论 2 2003-06-30 04:29

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2010 Nokia