anastaciocintra / escpos-coffee

Java library for ESC/POS printer
https://anastaciocintra.github.io/escpos-coffee
MIT License
281 stars 74 forks source link

Turkish setCharacterCodeTable problem? #27

Closed gokhanwork closed 4 years ago

gokhanwork commented 4 years ago

Describe the bug I am having problems sending Turkish characters. e.g ; ş,ı,ö,ç,,ü,ğ

anastaciocintra commented 4 years ago

Hi @gokhanplt, did you folow the sample CodeTableSample.java ? If yes, can you send the piece of code where you call the setCharacterCodeTable function and where you print Turkish characters?

gokhanwork commented 4 years ago

Hi @gokhanplt, did you folow the sample CodeTableSample.java ? If yes, can you send the piece of code where you call the setCharacterCodeTable function and where you print Turkish characters?

` PrintWriter out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(socket.getOutputStream()) ), true); EscPos escpos = new EscPos(socket.getOutputStream()); com.github.anastaciocintra.escpos.Style title = new com.github.anastaciocintra.escpos.Style() .setFontSize(com.github.anastaciocintra.escpos.Style.FontSize._3, com.github.anastaciocintra.escpos.Style.FontSize._3) .setJustification(EscPosConst.Justification.Center);

        com.github.anastaciocintra.escpos.Style subtitle = new com.github.anastaciocintra.escpos.Style(escpos.getStyle())
                .setBold(true)
                .setUnderline(com.github.anastaciocintra.escpos.Style.Underline.OneDotThick);
        com.github.anastaciocintra.escpos.Style bold = new com.github.anastaciocintra.escpos.Style(escpos.getStyle())
                .setBold(true);
        escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.CP850_Multilingual);
       // escpos.setCharsetName("ZJ-8330");
        Toast.makeText(ActivityOdeme.this, "CharSet Naeee  " + escpos.getDefaultCharsetName(), Toast.LENGTH_LONG).show();
        escpos.writeLF(title,"işçıüĞğ").feed(3).write("Tar: ");
            escpos.writeLF(subtitle, "ışöğüç")
                    .feed(3)
                    .writeLF(" Patates                   12  TL");
            escpos.writeLF("----------------------------------------")
                    .feed(2)
                    .writeLF(bold,
                            "Tutar:                              12 TL");*/
        escpos.writeLF("----------------------------------------")
                .feed(8)
                .cut(EscPos.CutMode.FULL);

        escpos.close();
        out.close();
        socket.close();`
anastaciocintra commented 4 years ago

@gokhanplt, I have one Epson TM-T20 and in my tests, the printer output was seems to be good, but the folow piece of code was need to be changed:

//escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.CP850_Multilingual);
escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.WCP1254_Turkish);

or if you want, you can use:

escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.CP857_Turkish);

For me, the "WCP1254_Turkish" was better.

If your printer isn't compatible with this code table, we will need to go back to the documentation and understand how to best use...

if possible, send me one feedback about the result.

gokhanwork commented 4 years ago

escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.WCP1254_Turkish); escpos.writeLF(title,"işçıüĞğ").feed(3).write("Tar: "); WhatsApp Image 2019-11-29 at 3 35 27 PM escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.CP857_Turkish); escpos.writeLF(title,"işçıüĞğ").feed(3).write("Tar: "); WhatsApp Image 2019-11-29 at 3 33 08 PM (1)

and printer info WhatsApp Image 2019-11-29 at 3 33 08 PM

anastaciocintra commented 4 years ago

Ok, I'm searching about ip8025use programming manual on google, but unfortunetly I didn't find. Do you have any material of producer to share with us?

anastaciocintra commented 4 years ago

@gokhanplt, do you have a programming manual of your printer?

gokhanwork commented 4 years ago

@gokhanplt, do you have a programming manual of your printer?

I'm not sorry. http://inter-pos.com/driver/ iprinter rp8025use

anastaciocintra commented 4 years ago

@gokhanplt ,

The escpos-coffee library uses the combination of two features: 1 java String Encoding and printer character code table.

you can read more about java String encoding on (https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html)

use the setCharsetName function to set the charset java encoding, for example:

escpos.setCharsetName("cp1254");

and, to set the chacode table of the printer (ESC t n), uses the setPrinterCharacterTable function:

escpos.setPrinterCharacterTable(29);

having the document (that you sent) '58 Command Set.pdf' as the reference, I understood that the combinations of Turkish configuration of your printer are:

1. | 29 - CP857[Turkish]

            escpos.setCharsetName("cp857");
            escpos.setPrinterCharacterTable(29);

2.| 32 WCP1254[Turkish]

            escpos.setCharsetName("cp1254");
            escpos.setPrinterCharacterTable(32);

3.| 43 ISO-8859-9[Turkish]

            escpos.setCharsetName("ISO_8859-9");
            escpos.setPrinterCharacterTable(43);

Testing

so, for your tests, you can use the same code as before, except by changing these lines:

//            escpos.setCharacterCodeTable(EscPos.CharacterCodeTable.WCP1254_Turkish);
// change the line above by two lines below
            escpos.setCharsetName("cp857");
            escpos.setPrinterCharacterTable(29);

            escpos.writeLF(title,"işçıüĞğ").feed(3).write("Tar: ");
            escpos.writeLF(subtitle, "ışöğüç")

// ...

make the same test for the 3 configurations and see what is best for you....

I hope that it will work,

please, don't forget your feedback of your tests...

anastaciocintra commented 4 years ago

as there were no returns, I understand that everything is fine. then I'm closing this issue.