Message8820

Author zyasoft
Recipients jeff.allen, kasso, rpan, zyasoft
Date 2014-06-25.06:06:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403676397.71.0.123734412849.issue2123@psf.upfronthosting.co.za>
In-reply-to
Content
Rose, you need to use unicode, not str. Jython 2.2 had the old, noncompliant behavior that unicode = str. Since 2.5, we have switched to the behavior that unicode means Unicode, str is made up of 8-bit characters. Sometimes this can be confusing, depending on console encoding, so for example my console has UTF-8 encoding, and so for printing it comes out the same. But as you can see, the types are otherwise different:

$ jython
Jython 2.7b3+ (default:68912d04f6f5, Jun 24 2014, 23:57:53)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_21
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "使用"
>>> s
'\xe4\xbd\xbf\xe7\x94\xa8'
>>> print s
使用
>>> u = u"使用"
>>> u
u'\u4f7f\u7528'
>>> print u
使用
>>> print len(s)
6
>>> print len(u)
2
History
Date User Action Args
2014-06-25 06:06:37zyasoftsetmessageid: <1403676397.71.0.123734412849.issue2123@psf.upfronthosting.co.za>
2014-06-25 06:06:37zyasoftsetrecipients: + zyasoft, jeff.allen, rpan, kasso
2014-06-25 06:06:37zyasoftlinkissue2123 messages
2014-06-25 06:06:37zyasoftcreate