BluetoothSerial icon indicating copy to clipboard operation
BluetoothSerial copied to clipboard

链接打印机 打印中文乱码

Open afei1217 opened this issue 6 years ago • 4 comments

afei1217 avatar Sep 03 '18 10:09 afei1217

@chenyongfei Happy new year, do u fix it now ? And can u tell me that how to print data from bluetooth pos printer?

uokivan avatar Dec 31 '18 17:12 uokivan

bluetooth.write("新年快乐");

afei1217 avatar Jan 02 '19 03:01 afei1217

@chenyongfei bluetooth.write("新年快乐");

I don't know why , 現在還是乱码...

uokivan avatar Jan 02 '19 11:01 uokivan

@chenyongfei https://github.com/don/BluetoothSerial#write

According to document:

String conversion assume 8bit characters.

You might need to convert from UTF-8 <-> ASCII.

有试过转换编码么? 按照说明文本, 写入的文字都会使用ASCII, 对UTF-8的文字可能无直接支援

function encode_utf8(s) {
  return unescape(encodeURIComponent(s));
}

function decode_utf8(s) {
  return decodeURIComponent(escape(s));
}

husano896 avatar Feb 13 '19 00:02 husano896