ASCII To Octal
This algorithm converts ASCII code to octal numbers.
Public Shared Function ASCIIToOctal(str As String) As String
Dim oct As String = String.Empty
For i As Integer = 0 To str.Length - 1
Dim cOct As String = DecimalToOctal(AscW(str(i)))
If cOct.Length < 3 Then
cOct = cOct.PadLeft(3, "0"c)
End If
oct += cOct
Next
Return oct
End Function
Private Shared Function DecimalToOctal(dec As Integer) As String
If dec < 1 Then Return "0"
Dim octStr As String = String.Empty
While dec > 0
octStr = octStr.Insert(0, (dec Mod 8).ToString())
dec = Int(dec / 8)
End While
Return octStr
End Function
Example
Dim data = "Programming Algorithms"
Dim value = ASCIIToOctal(data)
Output
120162157147162141155155151156147040101154147157162151164150155163