'Printer is printing Korean characters when Arabic CodePages are specified
Printer: Yujin Thermal Printer
Library: ESC-POS-.NET (C#)
Different Diagnostics done so far:
- Printed Arabic words using Notepad / Wordpad/ MS Word, Arabic characters prints perfect.
- Printed Arabic characters using wrong codepage, prints question marks as placeholders for Arabic characters.
Code:
var e = new EPSON();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Encoding enc = Encoding.GetEncoding(1256);
var bytes = ByteSplicer.Combine(
e.CodePage(CodePage.WPC1256_ARABIC),
e.CenterAlign(),
e.PrintLine(" Test Page See the Arabic text Below WPC1256_ARABIC"),
enc.GetBytes("طباعة صفحة إختبار "),
e.PrintLine("\x1D\x56\x42\x00"),
e.CodePage(CodePage.PC720_ARABIC),
e.CenterAlign(),
e.PrintLine(" Test Page See the Arabic text Below PC864_ARABIC"),
enc.GetBytes("طباعة صفحة إختبار "),
e.PrintLine("\x1D\x56\x42\x00"),
e.CodePage(CodePage.PC864_ARABIC),
e.CenterAlign(),
e.PrintLine(" Test Page See the Arabic text Below PC864_ARABIC"),
enc.GetBytes("طباعة صفحة إختبار "),
e.PrintLine("\x1D\x56\x42\x00"),
e.CodePage(CodePage.PC864_ARABIC),
);`
This is the method I use to send bytes to printer. I hope I am not loosing any byte data.
public static bool SendBytesToPrinter(string szPrinterName, byte[] data)
{
var pUnmanagedBytes = Marshal.AllocCoTaskMem(data.Length); // Allocate unmanaged memory
Marshal.Copy(data, 0, pUnmanagedBytes, data.Length); // copy bytes into unmanaged memory
var retval = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, data.Length);
Marshal.FreeCoTaskMem(pUnmanagedBytes); // Free the allocated unmanaged memory
return retval;
}
These are the Korean characters that gets printed: "핸 턱한"
I have opened a github issue on this as well
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

