0
votes

I have a POS-80C thermal printer, printing to it using PrinterUtility Library from NuGet. This library converts a string to ByteArray and sends it to the printer directly, so it's RAW printing. it works really well with Latin characters, but not with Hebrew or Arabic. it Prints "???" when the characters are not in English. I know that I must use ESC/POS commands to switch to for example Arabic character sets when my text is in Arabic but I tried a lot and figure out how to do so.

PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson();
var BytesValue = Encoding.ASCII.GetBytes(string.Empty);

BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("English Text")); //works fine
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes(String.Format("{0,-25}", "تيست"))); //Arabic Charecter, prints as ????

I know that somewhere in between the English and Arabic text I have to switch to Arabic Character Set

    BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("English Text")); 

//Here i have to switch To Arabic Charecter set
    BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.Unicode.GetBytes(String.Format("{0,-25}", "تيست")));


//Here I have to switch back To English Character set

And then send the file containing byte array to the printer

 if (File.Exists("Receipt")
                File.Delete("Receipt");
            File.WriteAllBytes(txtPrinterName.Text, BytesValue);
            RawPrinterHelper.SendFileToPrinter("PrinterName", "Receipt");

My printer does support Arabic, but it's a matter for sending command to switch to it or to any other language.

If you could teach me how to do this, I will appreciate it.

1
These are EPSON materials. ESC t, ESC R Get and look up these equivalent materials for your printer.kunif

1 Answers

0
votes

I haven't been able to find the command reference for your exact printer model, so some of this is going to be guess work from experience. The closest I could find was this command reference from POS-X.

You are correct that special commands are prefixed with ESC. In this particular case, the command you want is ESC t - Select character code table to change the code page. The code page you want is PC864 - Arabic which is 37 decimal (25 hexidecimal). The code page for English is simply 0 for PC437 - English.

I'm not exactly sure how the PrinterUtility package functions and I couldn't find any documentation for it either.

Essentially, you need to send the following:

byte[] CodePageArabic = new byte[] { 0x1B, 0x74, 0x25 };
byte[] CodePageEnglish = new byte[] { 0x1B, 0x74, 0x00 };