0

I'm trying to print Chinese characters to a thermal receipt printer using NodeJS with the node-thermal-printer module.

printer1.setCharacterSet('CHINA');

  var str = "   כ所有人生而自由,在尊嚴和權利上一律平等";
  var enc = iconv.encode(str, 'CP936');
  console.log (enc);
  var enc1 = iconv.encode(enc, 'ISO-8859-1');
  console.log (enc1);

  printer1.println(enc1);
  printer1.partialCut();
  printer1.execute()
  .then(() => {
    console.log('Printing...');
    printer1.clear();
  })
  .catch((err) => {
    console.log(err);
  })

I've read this answer Printing simplified Chinese characters on Epson TM-T88IVM explaining that the string first has to be encoded in CP936 and then represented in ISO-8859-1 for it to be printed properly.

All I'm getting right now is question marks. Is the character set or code page not setup properly? Am I encoding the string improperly?

I would really appreciate it if anyone can guide me in the direction.

jasnlink
  • 331
  • 2
  • 8

1 Answers1

0

The article you are referring to is information when using another API called OPOS, and the reference article in it seems to be general knowledge in C#.
They would not be applicable when using node-thermal-printer.

In the node-thermal-printer example, it seems that the string is printedln after simply setting characterset.
node-thermal-printer/examples/charsets.js

printer.println("Č芚ĆćĐđŽž");
printer.drawLine();
printer.setCharacterSet('PC855_CYRILLIC');
printer.println("Все люди рождаются свободными и равными в своем достоинстве и правах.");
printer.drawLine();
printer.setCharacterSet('JAPAN');
printer.println("すべての人々は自由に生まれ、尊厳と権利において平等です");
printer.drawLine();
printer.setCharacterSet('CHINA');
printer.println("所有人生而自由,在尊嚴和權利上一律平等");
printer.drawLine();
printer.setCharacterSet('PC862_HEBREW');
printer.println("כל בני האדם נולדים חופשיים ושווים בכבוד ובזכויות.");

By the way, in order to print East Asian characters such as Chinese/Japanese/Korean, it is necessary to use a printer model that incorporates those fonts.
Make sure you are using a model that can print them.

And you probably need to have the settings tool set up to print Chinese by default.
TM-T88V Utility

If you still can't print, why not submit an issue to the node-thermal-printer repository?

kunif
  • 4,060
  • 2
  • 10
  • 30
  • You're likely right, I might have a model that doesn't support East Asian characters, it's just weird that the TM-T88V Utility let's me set the charset to 'CHINA'. I can also print Chinese using Windows printing. I'm definitely submitting an issue to the repository like you mentioned. – jasnlink Jul 30 '21 at 16:23
  • If Windows printing is printing using the EPSON Advanced printer driver, it should create the print contents with image data and print it as a bit image. In that case, the printer doesn't need fonts, so it's unclear if there are Chinese fonts. Also, not only Chinese characters, but also ASCII range has characters that switch when set to China, so it is no wonder that there are setting items even if fonts are not supported. [International Character Sets](https://reference.epson-biz.com/modules/ref_charcode_en/index.php?content_id=3) – kunif Jul 30 '21 at 23:00