sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #28730
Re: [Question #255559]: [1.1.0] Windows: print u'2byte character' (unicode, utf-8) does not work on Windows
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.