paste() function with unicode fails

Asked by WD+WD

As I know, jython 2.5.2 is already in x1.0-rc3, so I didn't try to fix my problem with interactive mode or stuff. I read about this issue in many closed topics, but none of these answers really help me to fix this issue. Someone wrote in comments what simple line like paste(u"utf_string_here") works by default and the ticket is closed now. Another one wrote that it is windows problem. Ok then, I tried to change my regional settings in windows xp and windows 7 for non-unicode to russian. Also I tried x1.0 build 931 for these 2 configurations => another fail. After that I returned non-unicode to original value - english. Another fail. So, how can I fix this problem? Is there a single, straightforward explanation?

Thank you.

P.S Forget to mention - I want to paste russian characters.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- talking about the Jython level of Sikuli

評價很高耶!! 不過價錢真的很貴

The above line was produced here from Sikuli IDE by using:

x = "評價很高耶!! 不過價錢真的很貴"
print "a unicode string:", x # shows in message area
# a unicode string: 評價很高耶!! 不過價錢真的很貴
switchApp("Safari") # I am on Mac
paste(x)

I have tested a similar situation on my Win 7-32 and Firefox: works the same.

So current version of Sikuli IDE is fully unicode (utf8) aware.

This is done by telling Jython, that the coding in the processed script is utf8, by using the magic comment
# coding=utf8
Which is inserted internally in the first line of the script source, when running a script.

So as long, as you make sure, that your strings contain utf8-encoded text, paste() (which internally is nothing else than filling the clipboard using Java features and simulating a ctrl/cmd-v) should work, as long as the target GUI element is utf8-aware.

Revision history for this message
WD+WD (wd+wd) said :
#2

Just tested it. Doesn't work unfortunately. Even the print instruction gives me a ????? symbols. I'm afraid that the problem may lay in windows, if you haven't on your Mac. Or maybe java code that emulates a CTRL+C CTRL+V operation needs a review on windows platform.

P.S. tested on Windows 7 32bit, Chrome

Revision history for this message
RaiMan (raimund-hocke) said :
#3

As mentioned: this works for me on my Win7 32Bit.

So it would be helpful, to pack your .sikuli in a zip file and send it to me: https://launchpad.net/~raimund-hocke

BTW: using latest official Oracle/Sun Java (1.6.0-29)?

Revision history for this message
WD+WD (wd+wd) said :
#4

Of course, Java 6 29. Please check your email.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

Problem solved based on private e-mails and personal findings.

solution: newest version of rc3 and recommendations according faq 1766