我正在使用node-thermal-printer节点模块来打印一些越南语文本。我印了“ThànhphốHồChíMinh”进行测试。但它打印“?”如图所示,在几个地方。任何帮助将不胜感激以解决此问题。我还使用了文档中提到的不同字符集,例如WPC1258_VIETNAMESE,但情况仍然相同。我正在使用以下节点模块https://github.com/Klemen1337/node-thermal-printer
我测试过使用缓冲区数据而不是原始文本,并且看起来工作正常。但是我没有使用真正的打印机进行测试。
在以下代码段下运行,我的输出将像:
Thành phố Hồ Chí Minh
------------------------------------------------
const ThermalPrinter = require("node-thermal-printer").printer;
const PrinterTypes = require("node-thermal-printer").types;
(async () => {
let printer = new ThermalPrinter({
type: PrinterTypes.STAR,
interface: 'tcp://xxx.xxx.xxx.xxx',
characterSet: 'SLOVENIA',
removeSpecialCharacters: false,
lineCharacter: "-",
options: {
timeout: 1000
}
});
printer.setBuffer(Buffer.from("Thành phố Hồ Chí Minh\n"));
printer.drawLine();
console.log(printer.getText());
// I do not have any real printer
// try {
// await printer.execute();
// console.log("Print success.");
// } catch (error) {
// console.error("Print error:", error);
// }
})();