4

我有一台蓝牙打印机,我通常从我的 android 应用程序打印英文字符,但是当我写阿拉伯字符时,它会错误地打印它们。我在写入打印机时尝试对输出流进行编码,但没有结果。这是我的代码

  Set<BluetoothDevice> pairedDevices = mBluetoothAdapter
                    .getBondedDevices();
            if (pairedDevices.size() > 0) {
                for (BluetoothDevice device : pairedDevices) {


                    if (device.getName().equalsIgnoreCase("BlueTooth Printer")) {
                        mmDevice = device;
                        break;
                    }
                }
            }

这就是我打印数据的方式:

        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();
        }
    }
4

0 回答 0