Question #255559 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/255559

    Status: Answered => Solved

kumatta confirmed that the question is solved:
Thanks yuo so much,RaiMan.
Your script was tried on Sikuli.

01: #!/usr/bin/env python
02: # -*- coding: utf-8 -*-
03: import sys
04: import codecs
05: import java.lang.System as JS
06: #sys.stdin  = codecs.getreader('utf-8')(sys.stdin)
07: #sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
08: text = "字"
09: textu = unicd(text) # a wrapper for unicode(text, "utf-8") # instead one 
can use: text = u"字"
10: JS.out.println("plainJ: " + text)
11: JS.out.println("unicodeJ: " + textu)
12: popup("plain: " + text)
13: popup("unicode: " + textu)
14: print "plain:", text
15: print "unicode:" 
16: print unicode(text,"utf-8")

---------------------------------------------------------------first 
execution---------
plainJ: 字
unicodeJ: 字

plain: 字
unicode:
[error] script [ ttt2 ] stopped with error in line 16
[error] UnicodeEncodeError ( 'ascii' codec can't encode character u'\u5b57' in 
position 0: ordinal not in range(128) )

--------second execution----------
plainJ: 字
unicodeJ: 字

plain: 字
unicode:
[error] script [ ttt2 ] stopped with error in line 16
[error] UnicodeEncodeError ( 'ascii' codec can't encode character u'\u5b57' in 
position 0: ordinal not in range(128) )

The 1st time and the 2nd time were displayed correctly. 
========================
The 7th line"sys.stdout = codecs.getwriter('utf-8')(sys.stdout)"  was corrected 
effectively. 

--------first execution---------
plainJ: 字
unicodeJ: 字

plain: 字
unicode:
字

--------second execution----------
plainJ: 字
unicodeJ: 字

plain: 字
unicode:
字

----------Third execution -----------
plainJ: 字
unicodeJ: 字

plain: 字
unicode:
字

It becomes amusing whenever it performs "sys.stdout = 
codecs.getwriter('utf-8')(sys.stdout)"  .
I gave up the "print" of the double byte character.
Use of "Java's printin" is considered.

Thanks.

--kumatta--

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to