Search code examples
c#escpos

How do I prevent incorrect separated characters when printing receipts using ESC/POS in C#?


I have an application which print the receipt to receipt printer using ESC/POS. It needs to support Thai language.

When I tried to print Thai language, some of the characters are being separated like this photo:

photo

Here is my code:

printMSG = Command.ESC + "t" + Command.DecimalToCharString(27);
port.Write(printMSG);
var enc = Encoding.GetEncoding("windows-874");
string content = "ข้าวผัดอินโดนีเซียกับเครื่องเทศแบบดั้ง";
byte[] bytes = enc.GetBytes(content);
port.Write(bytes, 0, bytes.Length); 

Solution

  • enter image description here

    Here is the picture as I have described above in my comments. I have written a simple For..Next loop to print out the characters in the Thai codepage. From my picture I have highlighted the double char in the codepage and the char number of the Thai char.

    Also, the third the printout shows the my code printing out Thai sentences with three lines for each Thai sentence. The first and third sentence has three lines.