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.