I am trying to use Chr to send my string to thermal printer using ESC/POS commands. I have been using many Chr() and it works in B4J and B4A. However, B4i ignores Chr and convert the unicode into numbers. How to solve this issue? It also happen when I try to display the strings in a label.
__________________________________________________
Di perpustakaan saya untuk pencetakan BLE untuk iOs (terdapat di sini) saya menggunakan kaedah ini untuk menghantar rentetan (atau aksara)
Thanks Erel. Finally I get it to work! I can now build a B4J Print Server to print receipt for B4i app using bluetooth printer with no AirPrint support!
B4X:
Public Const eLEFT As String = "" & Chr(0x1B) & Chr(0x61) & Chr(0x00) ' ESC a NUL
Public Const eCENTRE As String = "" & Chr(0x1B) & Chr(0x61) & Chr(0x01) ' ESC a SOH
Public Const eRIGHT As String = "" & Chr(0x1B) & Chr(0x61) & Chr(0x02) ' ESC a STX
Public Const eCLEAR As String = "" & Chr(0x1B) & Chr(0x40) ' ESC @
Public Const eLINEFEED As String = "" & Chr(0x0D) & Chr(0x0A) ' CR LF
I am wondering why smart string literal is not working.
B4X:
Public Const eLEFT As String = "" & $"${Chr(0x1B)}${Chr(0x61)}${Chr(0x00)}"$ ' ESC a NUL
Public Const eCENTRE As String = "" & $"${Chr(0x1B)}${Chr(0x61)}${Chr(0x01)}"$ ' ESC a SOH
Public Const eRIGHT As String = "" & $"${Chr(0x1B)}${Chr(0x61)}${Chr(0x02)}"$ ' ESC a STX
Public Const eCLEAR As String = "" & $"${Chr(0x1B)}${Chr(0x40)}"$ ' ESC @
Public Const eLINEFEED As String = "" & $"${Chr(0x0D)}${Chr(0x0A)}"$ ' CR LF