I have a problem trying to convert ASCII to binary. In effect, I am translating an AIS frame (which I used for navigation on ships) symbol by symbol on six bits from 15 (where the payload begins). And despite having !AIVDM,1,1,,A,15O86n001TJ3KutH8ar@<h;l06Hh,0*5D
the translation is for each symbol: 1100001
.
Here the payload is: 15O86n001TJ3KutH8ar@<h;l06Hh
Public Sub decodage_AIS(tramaAs String)
Dim coleccion_ASCII(trames.ToString.Length) As String
Dim variable As Char
Dim binaryDigits() As Char
For i = 15 To tableau_ASCII.Length - 1
variable = trama(i)
equivalent_byte = equivalent_byte + System.Convert.ToString(Asc(variable), 2).PadLeft(4, "0")
binaryDigits = equivalent_byte.ToCharArray
My.Application.DoEvents()
Next
For example, 1
should be converted to 000001
but is converted to 1100001
like all other symbols, 5
in 000101
is converted to 1100001
.
Finally, I expect this conversion:
1 000001
5 000101
O 011111
8 001000
6 000110
n 110110
0 000000
0 000000
1 000001
T 100100
J 011010
3 000011
K 011011
u 111101
t 111100
8 001000
a 101001
r 111010
@ 010000
< 001100
h 110000
; 001011
l 110100
0 000000
6 000110
H 011000
h 110000
I have read the answer from user3947014 and also this from Pradeep Kumar for the question Convert from string to binary vb.net
** I think the problem comes from variable = trama(i)**