WeChat Mini Programs Bluetooth Printer

is connected to the printer, but the garbled code is printed. The problem now is that Mini Program"s Bluetooth interface requires the data to be written in the form of ArrayBuffer, while the printer needs to accept the gb2312 format. I save the print command locally, how to convert the string to gb2312, and then to ArrayBuffer? Bosses call for help ~

Mar.30,2021

use this library iconv-lite

import iconv from "iconv-lite"
let toWrite = iconv.encode (item.values, 'GBK');
let base64Value = toWrite .toString (' base64');


var hex = strToHexCharCode ("! 0200 200 560 1") + "0D0A" +

   strToHexCharCode("PAGE-WIDTH 450") + "0D0A" + 
   strToHexCharCode("TEXT 24 2 20 80 ") + strToHexCharCode(str) + "0D0A"+
    strToHexCharCode("PRINT") + "0D0A" 
  var typedArray = new Uint8Array(hex.match(/[\da-f]{2}/gi).map(function (h) { return parseInt(h, 16) }))
  var buffer1 = typedArray.buffer
  ~
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e193-2b932.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e193-2b932.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?