Displays characters when sending Cyrillic for printing. I checked all available encodings in the library by printing the text "Тест" and got no result.
The printer supports the Cyrillic alphabet, I checked it on the application from the market:
Here is the part of the code where I set the print data:
public void testPrint(View view){
ArrayList<Printable> printables = getTestPrint("Тест");
PairedPrinter printer = new PairedPrinter(name, mac);
Printooth.INSTANCE.printer(printer).print(printables);
}
public static ArrayList<Printable> getTestPrint(String text){
ArrayList<Printable> printables = new ArrayList<>();
Byte lineSpacing = (byte) Settings.lineSpacing(context);
int spaceAfter = Settings.spaceAfter(context);
printables.add(gerRawPrintable());
Map<String, Byte> bytes = Printer.getCharacterCode();
for(var entry: bytes.entrySet()){
printables.add(new TextPrintable.Builder()
.setText(entry.getKey() + " - " + text)
.setCharacterCode((byte) entry.getValue())
.setCustomConverter(new DefaultConverter())
.setAlignment(DefaultPrinter.Companion.getALIGNMENT_LEFT())
.setNewLinesAfter(spaceAfter)
.setLineSpacing(lineSpacing)
.build()
);
}
return printables;
}
public static RawPrintable gerRawPrintable(){
return new RawPrintable.Builder(new byte[]{27, 100, 4}).build();
}
public static Printable getPrintElement(String text, Byte lineSpacing, byte characterCode){
return new TextPrintable.Builder()
.setText(text)
.setAlignment(DefaultPrinter.Companion.getALIGNMENT_LEFT())
.setNewLinesAfter(Settings.spaceAfter(MainActivity.context))
.setLineSpacing(lineSpacing)
.setCharacterCode(characterCode)
.build();
}
public static Map<String, Byte> getCharacterCode(){
Map<String, Byte> bytes = new HashMap<>();
bytes.put("ARABIC CP720", DefaultPrinter.Companion.getCHARCODE_ARABIC_CP720());
...
bytes.put("WEU", DefaultPrinter.Companion.getCHARCODE_WEU());
return bytes;
}
I solved the problem by sending the text to print using the RavPrint class:
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
printables.add(new RawPrintable.Builder(bytes).setNewLinesAfter(1).build());