ESC/POS打印汉字命令
ESC/POS Command for Printing Chinese Character
打印机型号: Epson TM-T88V
ESC/POS 命令指南(见第 115 页): http://download.delfi.com/SupportDL/Epson/Manuals/TM-T88IV/Programming%20manual%20APG_1005_receipt.pdf
我搜索了很多关于此功能的帖子,但仍然找不到正确打印中文的解决方案。下面是我到目前为止尝试过的代码(仍然打印乱码文本):
Socket socket = new Socket("192.168.1.111", 9100); //one socket responsible for one device
PrintWriter printWriter = new PrintWriter(socket.getOutputStream()); //create a PrintWriter object
printWriter.println("HI,test from Android Device");
printWriter.println(""); //empty line
printWriter.println(new char[]{0x1B, 0x52, 0x15}); //codepage for simplified chinese, see the P.115 in the guide above
printWriter.println("中".getBytes("GB2312")); //character encoding stuff? Not sure how it works
printWriter.println("\n\n");
printWriter.println(new char[]{0x1D, 0x56, 0x41, 0x10}); //"0x1d, 0x56, 0x41" is for paper cut and "0x10" is for line feed
printWriter.close();
socket.close();
有人可以帮忙吗?非常感谢。
打印机型号: Epson TM-T88V
ESC/POS 命令指南(见第 115 页): http://download.delfi.com/SupportDL/Epson/Manuals/TM-T88IV/Programming%20manual%20APG_1005_receipt.pdf
我搜索了很多关于此功能的帖子,但仍然找不到正确打印中文的解决方案。下面是我到目前为止尝试过的代码(仍然打印乱码文本):
Socket socket = new Socket("192.168.1.111", 9100); //one socket responsible for one device
PrintWriter printWriter = new PrintWriter(socket.getOutputStream()); //create a PrintWriter object
printWriter.println("HI,test from Android Device");
printWriter.println(""); //empty line
printWriter.println(new char[]{0x1B, 0x52, 0x15}); //codepage for simplified chinese, see the P.115 in the guide above
printWriter.println("中".getBytes("GB2312")); //character encoding stuff? Not sure how it works
printWriter.println("\n\n");
printWriter.println(new char[]{0x1D, 0x56, 0x41, 0x10}); //"0x1d, 0x56, 0x41" is for paper cut and "0x10" is for line feed
printWriter.close();
socket.close();
有人可以帮忙吗?非常感谢。