Android (Java) With thermal printer and blue stacks does not print non-english words

柔情痞子 提交于 2020-02-06 23:49:30

问题


long story short, i have implemented an android restaurant application that runs on blue stacks 4, the app has a printing functionality that uses an Ethernet connection to print the receipts from a thermal printer.

the printer is set correctly as for now it prints test pages and receipts in English, but it does not print non-English words.

what i tried so far :

  • String str = new String("تعطي يونيكود رقما فريدا لكل حرف".getBytes(), "UTF-8"); and every other utf/iso related formatting but non seem to work

  • what i concluded so far : the printer prints on a c# programs. the printer is set up correctly. its not from the bluestacks default language.

and here is the code implemented in the function.

try {

      Socket socket = new Socket("192.168.123.101", 9100);
      PrintWriter pw = new PrintWriter(socket.getOutputStream());

      String s=  new String("محمد الزعبي".getBytes(),"UTF-8")  ;
      pw.println(s);
      pw.println("\n\n\n\f");
      pw.close();
      socket.close();
  } catch (Exception e) {
      new AlertDialog.Builder(Emppage.this).setMessage("error: "+e).show();
  }

来源:https://stackoverflow.com/questions/58153029/android-java-with-thermal-printer-and-blue-stacks-does-not-print-non-english-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!