0

I try to change the Default code page into PC858 (Multilanguage + Euro) for print the Symbol € .

But any ESC/POS command work.

So i try to send hex value of command :

    public void EnvoiCommande(byte donnee)
    {
        byte[] array = {donnee};
        _outStream.Write(array, 0, 1);
        _outStream.Flush();
    }



    public void ImpressionTicket(List<string> donnee, string appareil, Texture2D logo)
    {
      // Code Page
      EnvoiCommande(0x1b);
      EnvoiCommande(0x74);
      EnvoiCommande(0x13);

      foreach (var txt in donnee)
      {
         var ligne = txt;
         Encoding encoding = Console.OutputEncoding;
         byte[] originalBytes = encoding.GetBytes(ligne);
         byte[] outputBytes = Encoding.Convert(encoding,
         Encoding.GetEncoding("CP00858"), originalBytes);
         _outStream.Write(outputBytes, 0, outputBytes.Length);
         Thread.Sleep(10);
      }
    }

All of my text is print correctly but my symbol € don't work.

Thank in advance for your help, i have try many PDF, And test many similar questions about that, but anything don't work.

Heavenly
  • 11
  • 1
  • 7

3 Answers3

0

Encoding.GetEncoding returns a value which you must use.

Marc Balmer
  • 1,780
  • 1
  • 11
  • 18
  • I don't really understand, i convert my text with CP00858 (OEM858) , but I get chinese char with € symbol and on accent too. When i send command ESC/POS anything work , my printer print something like: AH – Heavenly May 28 '17 at 22:09
0

Have you tried to just send the bytecode for € to see if you have the correct code page?

https://en.wikipedia.org/wiki/Code_page_858

if you try to print 0xD5 and you get the € symbol then yes, you have the correct code page.

Then we know that the problem is when you convert the String to byteArray, check this out:

http://www.fileformat.info/info/unicode/char/20ac/index.htm

€ in unicode is: 0x20AC which is 0xE2 0x82 0xAC. So the € symbol transforms into 3 bytes that have other meaning for your printer. The printer prints this "Ôé¼" maybe?

If you only have trouble with the € symbols you can simply check the String before converting it to byte[].

if (ligne.contains("€"){
    ligne.replace("€",(char)0xD5);
}
  • Thank you, yes I had try, so for resolve that problem, I have buy another printer and that's work. The old printer don't save the page code when I change it. (BT-PRINT) – Heavenly Jul 25 '17 at 11:03
0

Send the "Character Table command" in one flush:

public void EnvoiCommande(params byte[] donnees)
{
   _outStream.Write(donnees, 0, 1);
   _outStream.Flush();
}

// Code Page
EnvoiCommande(0x1b, 0x74; 0x13);
BertrandJ
  • 29
  • 4