Print diacritic text in thermal printer – ESC POS commands

In this post I will show you how to print spanish text, text with accents or ñ letters on a thermal printer. I have been searching for this for a long time and now I want to share it.

Printing spanish text or diacritict text is necessary because sometimes the customer’s names or data contains some chars out of the ASCII range.

I will show you how to do this with JavaScript directly from the browser, but once you understand it, you will be able to print from any programming language.

Setup environment

To make this work, you need a free plugin that I have developed and also you need to share your printer. I encourage you to read the next post first:

Print ticket in thermal printer directly from browser

The next section assumes that you have already printed the “Hello world” receipt and your printer is working with the plugin as expected.

First: check if your printer accepts diacritict text out of the box

Some printers support diacritic text or accented text out of the box, you only have to print it. First we create a ConectorPluginV3 instance and then we call EscribirTexto which only write text to the printer:

I have a GOOJPRT PT210 printer and it is capable of printing text with diacritics out of the box:

Accented text in thermal printer out of the box
Accented text in thermal printer out of the box

But on the other hand I have a Xprinter-58 and when I try this example it prints chinese chars, so I have another solution below.

Forcing accented text in thermal printer

Now we will force the printer to print diacritic text by changing the charcode page. Remember that each printer is different and sometimes you will need to enable or disable certain things.

For example, when I want to print spanish text on my ESC POS Xprinter 58, I have to disable chinese char mode by calling DeshabilitarElModoDeCaracteresChinos and then call TextoSegunPaginaDeCodigos which generates encoded text through iconv.

The TextoSegunPaginaDeCodigos accepts the page number, encoding and text to encode. Then it prints the encoded text to the printer.

In my case, I have used page number 2 but instead of cp860 (as it should be), I specify cp850. With this, I have been able to print next text in my chinese printer:

cp850 con numero 2 ¿EL VELOZ MURCIÉLAGO

cp850 con número 2 ¿el veloz murciélago hindú comía feliz
cardillo y kiwi? ¡la cigüeña tocaba el saxofón detrás del palenque de paja!.

And the code looks like this:

If it does not work for you, try another page number combinations. For example you can use charcode page 3 and a different encoding. Anyway, the result receipt is as follows:

Spanish text with thermal printer - Print accented text on Chinese printer ESC POS
Spanish text with thermal printer – Print accented text on Chinese printer ESC POS

Full example: sales ticket

Now we can see a real example. Let’s print a sales receipt on a thermal printer, which contains diacritic text:

Sales receipt printed on thermal printer - Contains accented text
Sales receipt printed on thermal printer – Contains accented text

The source code is as follows:

There we are printing images, feeding paper, cutting, and so on. If you want to read the full list check this and also you can check the examples or the source code.

Custom character

Another alternative is to define a custom char in a 12×24 grid and then print it. You can design any character.

Learn how to do it in the next link:

Imprimir caracteres personalizados en impresora térmica

About charcode pages

The code pages vary depending on the printer. When printing on the printer, it is not necessary to indicate the encoding, but I do it because I convert the characters using iconv.

If it doesn’t work with a specific code page, you should try combining the page number and name or consult the documentation of your printer.

By the way, in this case, we did it with JavaScript, but the plugin also works with Python, C#, Java and any language that speaks HTTP. The connectors are listed at:

Remember that if you need help, you can send me a message at

I am available for hiring if you need help! I can help you with your project or homework feel free to contact me.
If you liked the post, show your appreciation by sharing it, or making a donation

Leave a Comment

Your email address will not be published. Required fields are marked *