hi
i was able to find a working code how to convert string to binary but how can i convert binary back to string??
this is how i convert string to binary:
and now how do i convert binary back to string?
any ideas?
thanx, ilan
i was able to find a working code how to convert string to binary but how can i convert binary back to string??
this is how i convert string to binary:
B4X:
Sub Button1_Click
Dim txt As String = "foo"
Dim res As String = ""
For Each b As Byte In txt.GetBytes("UTF8")
res = res & NumberFormat2(ToBinaryString(Bit.And(0xff, b)), 8, 0, 0, False)' & " "
Next
Log(res)
End Sub
Sub ToBinaryString(number As Int) As String
Dim sb As StringBuilder
sb.Initialize
Dim x As Int = Bit.ShiftLeft(1, 31)
For i = 0 To 31
Dim ii As Int = Bit.And(number, x)
If ii <> 0 Then sb.Append("1") Else sb.Append("0")
x = Bit.UnsignedShiftRight(x, 1)
Next
Return sb.ToString
End Sub
and now how do i convert binary back to string?
any ideas?
thanx, ilan