lsongdev / lsongdev/node-escpos

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

Open
#367 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.6k
Forks
443
PR merge metrics
No merged PRs in 30d

Description

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

This is my code

```js
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](https://user-images.githubusercontent.com/34961565/138746399-a4e87292-c6bc-4969-ac5d-dc024a8ea4ff.jpg)

Expected result

Should print `สวัสดี` in the paper

How to fix it?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue through the escpos.USB device, escpos.Printer options, and the .text("สวัสดี") call shown in the report. Trace how the UTF8 encoding option reaches the printer and compare the emitted data with the printer's Thai character support. Done means Thai text prints as สวัสดี rather than Chinese characters, with a regression check if the project provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.