SUB (Substitute) is ASCII code point 26 (0x1A), Unicode U+001A. It is a C0 control character that replaced a byte detected as erroneous during transmission — a teleprinter inserted 0x1A where the original character was unrecoverable. Ctrl+Z emits it, and DOS repurposed that keystroke as its end-of-file marker: many Windows programs still treat 0x1A as EOF when reading text-mode streams, which is why binary files opened as text can be silently truncated. Unix ignored this convention entirely, using Ctrl+Z for SIGTSTP (suspend process) instead — a divergence that still causes confusion in cross-platform file handling. UTF-8 encodes it as the single byte 0x1A; Unicode classifies it as Cc (Control) with the alias SUBSTITUTE.
unsigned char b = 0x1A; // SUB / Ctrl+Zif (b == 0x1A) break; // stop at in-band EOF sentinelout[i++] = b; // only for text-mode conventions
SUB (ASCII 26) was originally used to indicate a substitution — a character that replaces one that couldn't be transmitted or displayed correctly. It's the 'I couldn't read this, so here's a placeholder' marker.
On Windows, Ctrl+Z sends SUB (ASCII 26), which acts as an end-of-file marker for text streams — a convention inherited from CP/M. On Unix, Ctrl+Z sends SIGTSTP (suspend the process), which is a completely different mechanism unrelated to the SUB character.
CP/M used SUB (0x1A) to mark end-of-file because its file system tracked sizes in 128-byte blocks, not individual bytes. DOS inherited this convention. That's why typing Ctrl+Z terminates console input on Windows — it's a 1970s workaround that stuck around.
If you're reading text files on Windows, be aware that some legacy tools insert 0x1A at the end. Opening files in binary mode ('rb' in Python) avoids this. For Unix, SUB has no special meaning and is just another control byte to sanitize.