3
我正在使用使用jython2.5.2的Sikuli(請參閱sikuli.org)。Jython的Java和Python級別的不同編碼
這裏是類地區的Java級別摘要:
public class Region {
// < other class methods >
public int type(String text) {
System.out.println("javadebug: "+text); // debug output
// do actual typing
}
}
在Pythonlevel有一個Wrapperclass:
import Region as JRegion // import java class
class Region(JRegion):
# < other class methods >
def type(self, text):
print "pythondebug: "+text // debug output
JRegion.type(self, text)
這可以作爲用於ASCII字符,但是當我使用ö,ä或ü作爲文本,發生這種情況:
// python input:
# -*- encoding: utf-8 -*-
someregion = Region()
someregion.type("ä")
// output:
pythondebug: ä
javadebug: ä
該字符似乎被錯誤地轉換y傳遞給Java對象時。
我想知道這裏究竟發生了什麼錯誤,以及如何解決這個問題,以便在javamethod中輸入的字符與pythonmethod中的輸入相同。 感謝您的幫助