android蓝牙打印机不打印阿拉伯语字符(UTF-8)
我有一台蓝牙打印机,我通常从android应用程序中打印英文字符,但当我写阿拉伯文字符时,打印错误。 我尝试在写入打印机时对outputstream进行编码,但没有结果。 这是我的密码android蓝牙打印机不打印阿拉伯语字符(UTF-8),android,printing,bluetooth,outputstream,bluetooth-socket,Android,Printing,Bluetooth,Outputstream,Bluetooth Socket,我有一台蓝牙打印机,我通常从android应用程序中打印英文字符,但当我写阿拉伯文字符时,打印错误。 我尝试在写入打印机时对outputstream进行编码,但没有结果。 这是我的密码 Set<BluetoothDevice> pairedDevices = mBluetoothAdapter .getBondedDevices(); if (pairedDevices.size() > 0) {
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter
.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName().equalsIgnoreCase("BlueTooth Printer")) {
mmDevice = device;
break;
}
}
}
你是如何生成阿拉伯字符串的,我的意思是使用哪种字体?默认情况下有一些字体是UTF-8,我在打印区域语言时也遇到了同样的问题。如果在日志上打印输出,打印的是什么阿拉伯文字母或一些编码字符?我在日志中写我打印的消息,它显示正常的阿拉伯文字符
06-17 15:29:54.719:D/mss(20871):امل
,那么你认为问题不在编码方法中吗?所以有些情况下使用字符串解码和编码,而且还取决于运行应用程序的环境。它还取决于字符串的编码方式,使用Android应用程序提供的BT聊天,使用两部手机,在第二部手机上发送相同的字符,检查其显示方式。那么你的意思是,如果我将其连接到wifi,它可以打印阿拉伯文字符吗?还是蓝牙不是问题?
void sendData() throws IOException {
try {
// the text typed by the user
String msg = myTextbox.getText().toString();
msg += "\n";
mmOutputStream.write(msg.getBytes(Charset.forName("UTF-8")));
// tell the user data were sent
myLabel.setText("Data Sent");
} catch (NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}