gpt4 book ai didi

javascript - react-native-bluetooth-escpos-printer 编码土耳其语字符问题

转载 作者:行者123 更新时间:2023-11-30 06:11:47 25 4
gpt4 key购买 nike

我想将土耳其语打印参数从 react-native 应用程序发送到 bixolon spp-r310 打印机。

我的代码是:

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,
});
}
}

我试过编码 1254 和 ıso88959-9 以及编码 857(没有大写 İ 因此它没有)。

最佳答案

这是您的解决方案:

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

代码页非常重要。

关于javascript - react-native-bluetooth-escpos-printer 编码土耳其语字符问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58482140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com