Encoding Jython'中的不同编码;s的Java和Python级别

Encoding Jython'中的不同编码;s的Java和Python级别,encoding,character-encoding,jython,sikuli,jython-2.5,Encoding,Character Encoding,Jython,Sikuli,Jython 2.5,我正在使用Sikuli(参见Sikuli.org),它使用jython2.5.2 以下是Java级别的类区域摘要: public class Region { // < other class methods > public int type(String text) { System.out.println("javadebug: "+text); // debug output // do actual typing

我正在使用Sikuli(参见Sikuli.org),它使用jython2.5.2

以下是Java级别的类区域摘要:

public class Region {

    // < other class methods >

    public int type(String text) {
        System.out.println("javadebug: "+text); // debug output
        // do actual typing
    }
}
当传递给Java对象时,字符似乎转换错误

我想知道这里到底出了什么问题,以及如何解决这个问题,这样pythonmethod中输入的字符在javamethod中是相同的。
感谢您的帮助

从Jython代码看,您必须告诉Java,字符串是UTF-8编码的:

def type(self, text):
    jtext = java.lang.String(text, "utf-8")
    print "pythondebug: " + text  // debug output
    JRegion.type(self, jtext)
// python input:
# -*- encoding: utf-8 -*-
someregion = Region()
someregion.type("ä")

// output:
pythondebug: ä
javadebug: ä
def type(self, text):
    jtext = java.lang.String(text, "utf-8")
    print "pythondebug: " + text  // debug output
    JRegion.type(self, jtext)