lsongdev / node-escpos

🖨️ ESC/POS Printer driver for Node.js
https://npmjs.org/escpos
Other
1.38k stars 423 forks source link

UTF-8 not work for thai language (Always print chinese characters) #367

Open tchala120 opened 3 years ago

tchala120 commented 3 years ago

I have tried UTF-8 to print the Thai characters but I got Chinese characters instead.

This is my code

const escpos = require("escpos");

escpos.USB = require("escpos-usb");

const device = new escpos.USB();

const options = { encoding: "UTF8" };

const printer = new escpos.Printer(device, options);

device.open(function (error) {
  printer
    .size(0, 0)
    .font("a")
    .align("ct")
    .style("b")
    .text("สวัสดี")
    .cut()
    .close();
});

This is the result

IMG_3898

Expected result

Should print สวัสดี in the paper

How to fix it?

andrefmandrade commented 3 years ago

try this instead const options = { encoding: '860' };

keittisak commented 2 years ago

can't work

zangab commented 2 months ago

Guess you need to use 874, see https://de.wikipedia.org/wiki/Codepage_874