How to move from 8-bit ascii binaries to 6-bit ascii binaries?
For example, is there a link between H in 8-bit ASCII 0100 1000
and H in 6-bit ASCII 011000
?
I am referring to the article by Eric S. Raymond that was recently edited twice on the conversion tables between the ASCII and the binary. Here is how to recover the 6-bits. But not the binary:
To recover the six bits, subtract 48 from the ASCII character value; if the result is greater than 40 subtract 8.
if that is very clear for decimals
Char ASCII Decimal Bits
"0" 48 0 000000
"1" 49 1 000001
"2" 50 2 000010
"3" 51 3 000011
...
It is not for the letters
"H" 72 24 011000
I have made the following code to recover the binaries associated with the ascii symbols. But if I get 000001
for 1 in ASCII, which is successful, I get 1000101
for the letter u
instead of 111101
Module Module1
Public Function traduction_ASCII(trames As String)
Dim binario_en_8 As Integer = 0
Dim dec As Integer = 0
Dim Remainder As Integer
Dim result As String = ""
Dim j As Integer = 0
Dim tabular_binario(40) As String
'Modificamos los elementos ASCII en binarios'
For i = 0 To trames.Length - 1
'Recuperamos el valor numerica del ASCII leido en 8 bits'
binario_en_8 = Asc(trames.ElementAt(i))
'est esta necesario pero no se porque'
dec = Val(binaire_en_8)
'la modificamos en su valor ASCII en 6 bits'
dec = dec - 48
If dec > 40 Then
dec = dec - 8
End If
While dec > 0
remainder = dec Mod 2
dec /= 2
result = Remainder.ToString & result
j = j + 1
End While
While j < 6
result = "0" & result
j = j + 1
End While
tableau_binario(i) = result
result = ""
j = 0
Next
Return traduction_binaire_de_ASCII
End Function
End Module
The error is that for the program, 1F / 2 = 8
instead of 7
but I do not know why it divides in this way