UTF-8 字符不能用 Zebra 打印机打印

ZAJ*_*ZAJ 5 zpl-ii zebra-printers

我正在尝试在我的 Zebra Z410 标签打印机上打印波斯字符。但由于某种原因,它正在打印 ?????。我发送到打印机的 ZPL 代码是

^XA
^FO50,50
^PA1,1,1,1
^A@N,50,50,E:TT0003M_.TTF^FD??????????^FS
^XZ
Run Code Online (Sandbox Code Playgroud)

我正在使用 Zebra Setup Utilities-Open 与打印机通信。请帮忙!!

在此处输入图片说明

ban*_*nno 3

上面的示例没有指定 ^CI28,它允许您使用 UTF-8 而不是十六进制字段。

\n\n

^XA

\n\n

^FO50,50

\n\n

^PA1,1,1,1

\n\n

^A@N,50,50,E:TT0003M_.TTF^CI28^FD\xd8\xb9\xd8\xa7\xd8\xb3\xd8\xb4\xd8\xa7\xd8\xaa\xd8\xb9\xd9\x81 \xd8\xab\xd9\x87^FS

\n\n

^XZ

\n\n

Zebra Setup Utilities 无法正确处理 UTF-8。我刚刚使用 PuTTY 对网络打印机进行了测试,UTF 已正确处理。SDK中也有关于如何使用UTF-8打印的示例。

\n\n
     // Print a stored format with the given variables. This ZPL will store a format on a printer,\n // for use with example3.\n // This example also requires the ANMDS.TTF font to have been download to the printer prior to using this code.\n // ^XA^DFE:FORMAT3.ZPL\n // ^FS\n // ^FT26,223^FH^A@N,56,55,E:ANMDS.TTF^CI28^FH\\^FN12"Customer Name"^FS\n // ^FT26,316^FH\\^A@N,56,55,E:ANMDS.TTF^FH\\^FN11"Invoice Number"^FS\n // ^FT348,73^FH^A@N,39,38,E:ANMDS.TTF^FH\\^FN13"Vendor Name^FS\n // ^BY2,4^FT643,376^B7N,4,0,2,2,N^FH\\^FDSerial Number^FS\n // ^FO5,17^GB863,379,8^FS\n // ^XZ\n\n private void example3() throws ConnectionException {\n     Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);\n     try {\n         connection.open();\n         ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);\n         Map<Integer, String> vars = new HashMap<Integer, String>();\n         vars.put(12, "\xe4\xb8\x9c\xe9\xa3\x8e\xe4\xbc\x9f\xe4\xb8\x96\xe9\x80\x9a\xe6\xb1\xbd\xe8\xbd\xa6\xe9\xa5\xb0\xe4\xbb\xb6\xe7\xb3\xbb\xe7\xbb\x9f\xe6\x9c\x89\xe9\x99\x90\xe5\x85\xac\xe5\x8f\xb8"); // Customer Name\n         vars.put(11, "\xe8\xae\xa2\xe5\x8d\x95\xe5\x8f\xb7"); // Invoice Number\n         vars.put(13, "\xe4\xbe\x9b\xe5\xba\x94\xe5\x95\x86\xe5\x90\x8d\xe7\xa7\xb0"); // Vendor Name\n         printer.printStoredFormat("E:FORMAT3.ZPL", vars);\n     } catch (ConnectionException e) {\n         e.printStackTrace();\n     } catch (ZebraPrinterLanguageUnknownException e) {\n         e.printStackTrace();\n     } finally {\n         connection.close();\n     }\n }\n
Run Code Online (Sandbox Code Playgroud)\n\n

}

\n