Last updated
Basic Octal to Text Conversion
Convert space-separated octal values to readable text:
Input (octal): 110 145 154 154 157
Output (text): Hello
Input (octal): 110 145 154 154 157 40 127 157 162 154 144
Output (text): Hello World
Each octal number represents the ASCII value of one character. 110 in octal = 72 in decimal = 'H'. 145 = 101 decimal = 'e'. 40 = 32 decimal = space.
C String Octal Escape Sequences
Decode octal escape sequences found in C/C++ string literals:
C string: "\110\145\154\154\157"
Decoded: Hello
C string: "\101\102\103"
Decoded: ABC
C string: "\007"
Decoded: [BEL — bell character, ASCII 7]
C string: "\012"
Decoded: [LF — newline character, ASCII 10]
C string: "\011"
Decoded: [HT — horizontal tab, ASCII 9]
The backslash-prefixed format is standard in C, C++, Java, and many other languages. The converter recognizes both the space-separated and backslash-prefixed formats.
Unix File Permission Octal Values
Understanding octal in Unix file permissions (not text encoding, but same base):
chmod 755 script.sh
7 = 111 binary = rwx (owner: read, write, execute)
5 = 101 binary = r-x (group: read, execute)
5 = 101 binary = r-x (others: read, execute)
chmod 644 file.txt
6 = 110 binary = rw- (owner: read, write)
4 = 100 binary = r-- (group: read only)
4 = 100 binary = r-- (others: read only)
chmod 600 private.key
6 = 110 binary = rw- (owner: read, write)
0 = 000 binary = --- (group: no access)
0 = 000 binary = --- (others: no access)
Text to Octal Encoding
Convert text to octal escape sequences for use in C code or shell scripts:
Input text: API
Output octal: 101 120 111
Input text: Hello, World!
Output octal: 110 145 154 154 157 54 40 127 157 162 154 144 41
As C escape sequences:
"\110\145\154\154\157\54\40\127\157\162\154\144\41"
Octal to Decimal to Binary Reference
The relationship between octal, decimal, and binary:
Octal Decimal Binary ASCII
101 65 1000001 A
102 66 1000010 B
103 67 1000011 C
141 97 1100001 a
142 98 1100010 b
143 99 1100011 c
60 48 0110000 0
61 49 0110001 1
62 50 0110010 2
40 32 0100000 (space)
56 46 0101110 .
Each octal digit maps to exactly 3 binary bits, making octal-to-binary conversion straightforward. This is why early computers (PDP-8, PDP-11) used octal — their word sizes divided evenly into 3-bit groups.
Shell Script Octal Escape Sequences
Using octal in bash with printf and echo:
# Print a bell character (ASCII 7 = octal 7)
printf '\007'
# Print a tab character (ASCII 9 = octal 11)
printf '\011'
# Print Hello with octal escapes
printf '\110\145\154\154\157\n'
# Output: Hello
# echo with -e flag
echo -e '\110\145\154\154\157'
# Output: Hello
Decoding Octal in Python
Python handles octal escape sequences in string literals:
# Python octal escape sequences
s = "\110\145\154\154\157"
print(s) # Hello
# Convert octal string to text programmatically
octal_values = "110 145 154 154 157".split()
text = ''.join(chr(int(v, 8)) for v in octal_values)
print(text) # Hello
# Convert text to octal
text = "Hello"
octal = ' '.join(oct(ord(c))[2:] for c in text)
print(octal) # 110 145 154 154 157
Multi-Byte UTF-8 in Octal
Non-ASCII characters encoded as multi-byte octal sequences:
Character: é (U+00E9)
UTF-8 bytes: 0xC3 0xA9
Octal: 303 251
Character: 中 (U+4E2D)
UTF-8 bytes: 0xE4 0xB8 0xAD
Octal: 344 270 255
// In a C string
"\303\251" // é
"\344\270\255" // 中
Multi-byte UTF-8 characters require multiple octal escape sequences — one per byte. The converter handles these sequences and correctly reconstructs the Unicode characters.
Octal vs Hexadecimal
Comparison of the two common encoding bases:
Character: A (ASCII 65)
Octal: 101 (3 digits)
Hex: 41 (2 digits)
Character: Z (ASCII 90)
Octal: 132 (3 digits)
Hex: 5A (2 digits)
// Hex is more compact — 2 digits per byte vs 3 in octal
// Octal maps directly to binary (3 bits per digit)
// Hex maps to 4 bits per digit
// Modern preference: hexadecimal
// Legacy systems: octal (Unix permissions, C escape sequences)
Hexadecimal has largely replaced octal in modern computing, but octal remains in use for Unix file permissions and in C string literals where it was established early in the language's history.