← Back to team overview

sikuli-driver team mailing list archive

[Bug 1379722] Re: [1.1.0] Windows: print u'2byte character' (unicode, utf-8) does not work

 

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
import java.lang.System as JS
#sys.stdin = codecs.getreader('utf-8')(sys.stdin)
#sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
text = "字"
textu = unicd(text) # a wrapper for unicode(text, "utf-8")
# instead one can use: text = u"字"
JS.out.println("plainJ: " + text)
JS.out.println("unicodeJ: " + textu)
popup("plain: " + text)
popup("unicode: " + textu)
print "plain:", text
print "unicode:"
print unicode(text,"utf-8")

--- getting this output on Mac
plainJ: å­—
unicodeJ: 字
plain: å­—
unicode:
字

with the popups showing the expected output.


** Description changed:

- This is the sample code about which I worry. 
+ ********* 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.getreader('utf-8')(sys.stdin)
  sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
  
  print unicode("漢字","utf-8")
  --------
  "漢字" is 2byte character.
- An error does not occur. 
- However, it is not displayed normally. 
+ An error does not occur.
+ However, it is not displayed normally.
  
- First, sikuli-IED is started. 
+ First, sikuli-IED is started.
  First execution :
-   漢字
-   >>In the first execution, it is displayed normally. 
+   漢字
+   >>In the first execution, it is displayed normally.
  Second execution :
-   漢字
-   >>In the second execution, a display is wrong. 
+   æ¼¢å­—
+   >>In the second execution, a display is wrong.
  Third execution :
-   漢字
-   >>The third execution is wrong in a display further again. 
+   Ã¦Â¼Â¢Ã¥Â­Â—
+   >>The third execution is wrong in a display further again.
  Fourth execution :
-   漢字
+   ÃƒÂ¦Ã‚¼Â¢Ã¥Â­Â—
  Fifth execution :
-   漢字
+   ÃƒÂƒÃ‚¦Ã‚¼Â¢Ã¥Â­Â—
  Sixth execution :
-   漢字
+   ÃƒÂƒÃ‚ƒÃ‚¦Ã‚¼Â¢Ã¥Â­Â—
  7th execution :
-   漢字
+   ÃƒÂƒÃ‚ƒÃ‚ƒÃ‚¦Ã‚¼Â¢Ã¥Â­Â—
  
- It becomes strange rapidly. 
+ It becomes strange rapidly.
  May I know how to resolve this issue? Thanks!

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1379722

Title:
  [1.1.0] Windows: print u'2byte character' (unicode, utf-8) does not
  work

Status in Sikuli:
  In Progress

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.getreader('utf-8')(sys.stdin)
  sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

  print unicode("漢字","utf-8")
  --------
  "漢字" 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!

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1379722/+subscriptions


References