I have an Android app and I'm trying to print some texts with it that contain non-latin characters.
I'm using this code to send ESC t n
command to the printer:
byte[] buf = new byte[]{0x1B, 0x74, (byte)2}; // 2 is the codetable for PC850: Multilingual
this.mBaseOutputStream.write(buf);
Then, I try to print my code like this:
this.mBaseOutputStream.write("Лорем ăîîîîîîă".getBytes("cp850"));
But all I get for the non-latin characters are weird symbols. So what am I doing wrong?
Not sure this is an answer as such, but hopefully this will get things started. Also need a bit of room to explain...
It looks like code page 850 doesn't have the characters needed. An easy way to check this offline is to convert back to a String
. E.g. :
System.out.println(
new String("Лорем ăîîîîîîă".getBytes("cp850"), "cp850"));
--> ????? ?îîîîîî?
Clearly only the î
is available there.
You may need to do some experiments with alternative code pages - what type of printer is this?
A couple of tests here suggest the example string may need more than one code page, but someone else may know better:
System.out.println(
new String("Лорем ăîîîîîîă".getBytes("cp852"), "cp852"));
--> ????? ăîîîîîîă
System.out.println(
new String("Лорем ăîîîîîîă".getBytes("cp855"), "cp855"));
--> Лорем ????????
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With