The following sequence is an escape sequence for a Bluetooth printer, so that the printer could know that the string following this sequence should be encoded into a QR code.
[27, 90, 0, 2, 7, 23, 0]
This sequence should be encoded in hexadecimal string format :
let str = ''
str = str + "\x1b" + "\x5a" + "\x00" + "\x02" + "\x07" + "\x17" + "\x00"
Where each "\xab" value is the hexadecimal representation of each number presented in the sequence.
The "23" ("17" in hex) value, is the length of the text that should be encoded into QR, consequently, its value is dynamic, hence its hex value should be concatenated dynamically to 'str'.
Using string concatenation :
str = ...etc... + "\x07" + "\x" + generateHex("23") (generateHex converts decimal value to Hex)
resulted in an error because "\x" expects a hexadecimal digit sticked to it.
Using a double backslash to escape "\x" did not work either (it was not interpreted as valid Hex value).
Your Help is appreciated.