Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native-bluetooth-escpos-printer Encoding Turkısh Chracter Problem

I want to send print Turkish parameter from react-native app to bixolon spp-r310 printer.

My Code is :

async print(BBcolumn, txtObj, isBold, addEnterCount, barcode) {
         let txt = null;
           let result = ‘’;
           let space = ‘’;
           try {
               txt = txtObj;
           } catch (e) {
               console.log(‘Print Methot error : ’ + e);
           }
           let spaceLen = BBcolumn.Lenght - txt.toString().length;
           for (var a = 0; a < spaceLen; a++) {
               space += ' ';
           }
           if (BBcolumn.TextAlign === ‘right’) {
               result = space + txt;
           } else if (BBcolumn.TextAlign === ‘left’) {
               result = txt + space;
           }
           isBold === true ? BluetoothEscposPrinter.setBlob(1) : BluetoothEscposPrinter.setBlob(0);
           for (var i = 0; i < addEnterCount; i++) {
               result += ‘\r\n’;
           }
           if (barcode === true) {
               await BluetoothEscposPrinter.printerInit();
               await BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.CENTER);
               await BluetoothEscposPrinter.printBarCode(txtObj.toString(), BluetoothEscposPrinter.BARCODETYPE.CODE128, 3, 70, 0, 2);
               await BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.LEFT);
               await BluetoothEscposPrinter.printText(‘\f’, {});
           } else {
               // console.log(result);
               await BluetoothEscposPrinter.printText(result.replace(‘null’, ‘’),
                   {
                       encoding: ‘CP1254’,
                       fonttype: 1,
                   });
           }
       }

I tried Encoding 1254 and ıso88959-9 and encoding 857(There is not Capital İ therefore It doesn't).

like image 784
veliyetisgengil Avatar asked Jun 20 '26 16:06

veliyetisgengil


1 Answers

Here is your solution:

await BluetoothEscposPrinter.printText(result.replace('null', ''),
{
    codepage: 25,
    encoding: 'windows-1254',
    fonttype: 1,
});

codepage is very important.

like image 171
Yusuf Avatar answered Jun 23 '26 04:06

Yusuf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!