Octal To ASCII
This algorithm converts octal numbers to ASCII code.
public static string OctalToASCII(string oct)
{
string ascii = string.Empty;
for (int i = 0; i < oct.Length; i += 3)
{
ascii += (char)OctalToDecimal(oct.Substring(i, 3));
}
return ascii;
}
private static int OctalToDecimal(string octal)
{
int octLength = octal.Length;
double dec = 0;
for (int i = 0; i < octLength; ++i)
{
dec += ((byte)octal[i] - 48) * Math.Pow(8, ((octLength - i) - 1));
}
return (int)dec;
}
Example
string data = "120162157147162141155155151156147040101154147157162151164150155163";
string value = OctalToASCII(data);
Output
Programming Algorithms