mazenrashed / Printooth

A well documented, high-level Android interface that makes printing via bluetooth printers easier
Mozilla Public License 2.0
401 stars 114 forks source link

printer didn't print any arabic letters #85

Open amalnafia opened 3 years ago

ahmedsaber00 commented 2 years ago
public static byte[] POS_Print_Text(String pszString, String encoding, int codepage, int nWidthTimes, int nHeightTimes, int nFontType) {
        if (codepage < 0 || codepage > 255 || pszString == null || pszString.length() < 1) {
            return null;
        }
        try {
            byte[] pbString = pszString.getBytes(encoding);
            Command.GS_ExclamationMark[2] = (byte) (new byte[]{0, 16, 32, 48}[nWidthTimes] + new byte[]{0, 1, 2, 3}[nHeightTimes]);
            Command.ESC_t[2] = (byte) codepage;
            Command.ESC_M[2] = (byte) nFontType;
            if (codepage == 0) {
                return Other.byteArraysToBytes(new byte[][]{Command.GS_ExclamationMark, Command.ESC_t, Command.FS_and, Command.ESC_M, pbString});
            }
            return Other.byteArraysToBytes(new byte[][]{Command.GS_ExclamationMark, Command.ESC_t, Command.FS_dot, Command.ESC_M, pbString});
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }
printable.add(
            RawPrintable.Builder(
                PrinterCommand.POS_Print_Text(
                    "الأسم:\n",
                    ARABIC, 22, 0, 0, 0
                )
            ).build()
        )
    const val ARABIC = "ISO-8859-6"
Abdullqadir commented 2 years ago

What happened with this issue? @ahmedsaber00, does this code resolve the issue?

AhmedTawfiqM commented 11 months ago

https://stackoverflow.com/a/73602498