B4J Question chr to byte ?

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

How to move a character to array element as following packet(1) ?

Dim packet(64) As Byte

packet(0) = ENQ
packet(1) = '0'
 

Cableguy

Expert
Licensed User
Longtime User
Since you are casting your array as byte, it will expect bytes as values.
When you enclose a value with quote signs, it becomes a string!
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
You can use Asc("0") to get the code point of the character.
Thank's and My longer code : :(
B4X:
private Sub ascii(ch As String) As Byte
    Dim data() As Byte
    data=ch.GetBytes("UTF8")
    Return data(0)
End Sub
 
Upvote 0
Top