android - MonkeyRunner 中的西里尔文字

标签 android python unicode monkeyrunner

我正在尝试使用 MonkeyRunner 在我的 Android 设备上输入西里尔文字,但它要么不输出任何内容,要么只输出问号(“?”)字符。

代码:

print (sys.getdefaultencoding())
print (locale.getpreferredencoding())
print (sys.stdout.encoding)

提供以下输出:

ascii
None
Cp1251

我尝试了以下方法来显示文本:

device.type('Мой текст')  #This code type nothing
device.type(u'Мой текст') #This code type nothing
device.type(unicode('Мой текст','cp1251')) #This code type nothing
device.type(unicode('Мой текст','cp1251').encode('utf8')) #This code type nothing
device.type(u"\u0410".encode('utf8')) #This code type ??
device.type("\xe2\x98\x83".decode('utf8')) #This code type ?

使用编码/解码方法或任何其他方式通过 device.type() 显示西里尔字符的正确方法是什么?

最佳答案

参见 ADBKeyBoard:https://github.com/senzhk/ADBKeyBoard

device.shell("am broadcast -a ADB_INPUT_TEXT --es msg 'Серёжа'")

关于android - MonkeyRunner 中的西里尔文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16731019/

相关文章:

python - 去除图像背景并提取图像中的对象

python - Pillow ImageDraw 文本坐标居中

php - 如何反转 Unicode 字符串

python - Matplotlib 中的非 ASCII 字符

ruby - 从 Ruby 中的国家代码获取表情符号标志

android - 如何将 .so 文件打包到我的 .aar 存档中?

android - 如何将android webview缩放到特定高度

java - 在 EditText 中添加一个字符

javascript - 无法在 Android 设备上的 Javascript 中获取触摸事件的坐标

python - Python 模块中的多个类