[1.1.0] Windows: print u'2byte character' (unicode, utf-8) does not work
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SikuliX |
In Progress
|
High
|
RaiMan |
Bug Description
********* more information see comment #1
-------
This is the sample code about which I worry.
--------
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
import codecs
sys.stdin = codecs.
sys.stdout = codecs.
print unicode(
--------
"漢字" is 2byte character.
An error does not occur.
However, it is not displayed normally.
First, sikuli-IED is started.
First execution :
漢字
>>In the first execution, it is displayed normally.
Second execution :
æ¼¢å
>>In the second execution, a display is wrong.
Third execution :
æ¼¢åÂÂ
>>The third execution is wrong in a display further again.
Fourth execution :
æÃ
Fifth execution :
ÃÂÃ
Sixth execution :
ÃÂÃ
7th execution :
ÃÂÃ
It becomes strange rapidly.
May I know how to resolve this issue? Thanks!
I have to confirm this problem, but only on Windows (tested with version 1.1.0 which contains Jython 2.7b2 and with Java 7 and 8).
- the usage of the codecs module leads to the mentioned weird behavior.
Seems to be some Jython problem when using the same interpreter instance again (as is the case in Sikuli IDE when rerunning a script in the same IDE session).
--- running the below test script on Windows:
- the popups show the expected output
- on commandline, in the unicode situation ? are printed for each unicode character using the Java println
- the simple Python print refuses to work with unicode characters with a decoding error
this is the test script I used:
import codecs getreader( 'utf-8' )(sys.stdin) getwriter( 'utf-8' )(sys.stdout) println( "plainJ: " + text) println( "unicodeJ: " + textu) text,"utf- 8")
import java.lang.System as JS
#sys.stdin = codecs.
#sys.stdout = codecs.
text = "字"
textu = unicd(text) # a wrapper for unicode(text, "utf-8")
# instead one can use: text = u"字"
JS.out.
JS.out.
popup("plain: " + text)
popup("unicode: " + textu)
print "plain:", text
print "unicode:"
print unicode(
--- getting this output on Mac
plainJ: å
unicodeJ: 字
plain: å
unicode:
字
with the popups showing the expected output.