mtmsuhail / ESC-POS-USB-NET

This project is a simple .NET (C#) Implementation of the Epson ESC/POS Printing using USB Device Driver.
MIT License
202 stars 86 forks source link

Issues with existing _codepage definition #72

Open mafkas opened 3 months ago

mafkas commented 3 months ago

Dear all,

Currently when you initialize the printer the default codepage on the constructor is IBM860. I don't know if this code page is applied to the printer but certainly if you change this codepage does not applied to the printer.

Is used only to encode the data by this codepage.

private void AppendString(string value, bool useLf) { if (!string.IsNullOrEmpty(value)) { if (useLf) { value += "\n"; }

    List<byte> list = new List<byte>();
    if (_buffer != null)
    {
        list.AddRange(_buffer);
    }

    byte[] bytes = Encoding.GetEncoding(_codepage).GetBytes(value);
    list.AddRange(bytes);
    _buffer = list.ToArray();
}

}

Trying to print GREEK using the codepage IBM869 does nothing unless you send the necessary command to the printer //IBM869 // Alternatively, set code page to CP869 for Greek characters printer.Append(new byte[] { 0x1B, 0x74, 38 }); // CP869

My suggestion is that the codepage provided to the constructor send the required command to the printer also.

Thanks and hope that will help anyone facing this issue :)