Octal To ASCII

This algorithm converts octal numbers to ASCII code.



									Public Shared Function OctalToASCII(oct As String) As String
	Dim ascii As String = String.Empty

	For i As Integer = 0 To oct.Length - 1 Step 3
		ascii += ChrW(OctalToDecimal(oct.Substring(i, 3)))
	Next

	Return ascii
End Function

Private Shared Function OctalToDecimal(octal As String) As Integer
	Dim octLength As Integer = octal.Length
	Dim dec As Double = 0

	For i As Integer = 0 To octLength - 1
		dec += (CByte(AscW(octal(i))) - 48) * Math.Pow(8, ((octLength - i) - 1))
	Next

	Return CInt(Math.Truncate(dec))
End Function
								


Example

									Dim data = "120162157147162141155155151156147040101154147157162151164150155163"
Dim value = OctalToASCII(data)
								


Output

									Programming Algorithms