在android热敏打印机中打印阿拉伯字符 [英] Print Arabic characters in android Thermal Printer

查看:71
本文介绍了在android热敏打印机中打印阿拉伯字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打印机为 GoojPRT 便携式打印机 PT-210(热敏打印机)

相同的代码在另一台热敏打印机 POS 上工作,但不适用于这台打印机的阿拉伯字符,英文字符很好,但阿拉伯字符显示为中文字符

the same code is work on another thermal printer POS but not work on this printer for Arabic characters the English characters is good but the Arabic characters is shown as chinses characters

尝试添加编码为字符集"UTF-8"并且不适用于阿拉伯字符打印代码:

try to add encoded as charset " UTF-8 " and not working for Arabic characters the code for print :

Button btnPrint=(Button)findViewById(R.id.btnPrint);
        btnPrint.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Thread t = new Thread() {
                    public void run() {
                        try {
                            OutputStream os = mBluetoothSocket
                                    .getOutputStream();
                            BILL = "ENGLISH" + "\n";
                            BILL =  BILL + "العربية" + "\n";
                            BILL = BILL + "---------------" + "\n";
                            
                            os.write(BILL.getBytes( ));
                        } catch (Exception e) {

                        }
                    }
                };
                t.start();
            }
        });

扫描打印机:

Button btnScan = (Button) findViewById(R.id.btnScan);
        btnScan.setOnClickListener(new View.OnClickListener() {
            public void onClick(View mView) {
                mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
                if (mBluetoothAdapter == null) {
                    Toast.makeText(ActivityTest.this, "Error", Toast.LENGTH_SHORT).show();
                } else {
                    if (!mBluetoothAdapter.isEnabled()) {
                        Intent enableBtIntent = new Intent(
                                BluetoothAdapter.ACTION_REQUEST_ENABLE);
                        startActivityForResult(enableBtIntent,
                                REQUEST_ENABLE_BT);
                    } else {
                        ListPairedDevices();
                        Intent connectIntent = new Intent(ActivityTest.this,
                                DeviceListActivity.class);
                        startActivityForResult(connectIntent,
                                REQUEST_CONNECT_DEVICE);
                    }
                }
            }
        });

印刷样品

我需要打印文本而不是位图或图像

I need to print text not bitmap or image

推荐答案

尝试为阿拉伯文本添加 ISO-8859-6 编码.

Try to add ISO-8859-6 encode for arabic text.

这篇关于在android热敏打印机中打印阿拉伯字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆