Jython: how to paste chinese characters (unicode characters)
This solution only applies to scripts run by using a Jython interpreter directly or other Java based scripting solutions like JRuby.
For Jython you need 2 things:
--1. Python encoding directive
in the first or second line of your script you need a magic comment that defines the encoding used for the script:
# coding=utf-8
Of course: your script has to be stored as file with utf-8 encoding by your script editor.
--2. you have to tell the JVM, the same thing by giving this as a parameter when calling the JVM:
-Dfile.
Below in comments #4 and #5 find a description of a successful test with plain Jython by coldtest(https:/
This is not needed with scripts run with the support of Sikuli IDE or run with one of the approaches from http://
-------
I used the paste function to input the chinese to notepad in jruby script ,but it can't be correct in the notepad. they are distorted Character Code , the script as follow:
require 'rubygems'
require 'java'
require 'iconv'
java_import "org.sikuli.
java_import "org.sikuli.
java_import "org.sikuli.
java_import "org.sikuli.
screen=Screen.new
App.focus(
sleep(1)
str = "梅西"
sleep(2);
screen.
but it is correct when I use paste function in sikuli IDE ,the script as fellow:
App.focus(
sleep(3)
paste( ,"梅西")
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- Last query:
- Last reply: