A substitute character (␚) is a control character that is used in the place of a character that is recognized to be invalid or erroneous, or that cannot be represented on a given device. It is also used as an escape sequence in some programming languages.
In the ASCII and Unicode character sets, this character is encoded by the number 26 (1A hex). Standard keyboards transmit this code when the Ctrl and Z keys are pressed simultaneously (Ctrl+Z, by convention often described as ^Z).
End of fileEdit
Historically, under early PC CP/M 1 and 2 operating systems (and derivatives like MP/M) it was necessary to explicitly mark the end of a file (EOF) because the CP/M filesystem could not record the exact file size by itself; files were allocated in extents (records) of a fixed size, typically leaving some allocated but unused space at the end of each file. This extra space was filled with 1A16 (hex) characters under CP/M. The extended CP/M filesystems used by CP/M 3 and higher (and derivatives like Concurrent CP/M, Concurrent DOS and DOS Plus) did support byte-granular files, so this was no longer a physical requirement but a mere convention (especially for text files) in order to ensure backward compatibility.
In CP/M, 86-DOS, MS-DOS, PC DOS, DR-DOS, and their various derivatives, the SUB character was also used to indicate the end of a character stream, and thereby used to terminate user input in an interactive command line window (and as such, often used to finish console input redirection, e.g. as instigated by COPY CON: TYPEDTXT.TXT).
While no longer technically required to indicate the end of a file, many text editors and program languages still support this convention, or can be configured to insert this character at the end of a file when editing, or at least properly cope with them in text files. In such cases, it is often termed a "soft" EOF, as it does not necessarily represent the physical end of the file, but is more a marker indicating that "there is no useful data beyond this point". In reality, more data may exist beyond this character up to the actual end of the data in the file system, thus it can be used to hide file content when the file is entered at the console or opened in editors. Many file format standards (e.g. PNG or GIF) include the SUB character in their headers to perform precisely this function. Some modern text file formats (e.g. CSV-1203) still recommend a trailing EOF character to be appended as the last character in the file. However, typing Control+Z does not embed an EOF character into a file in either MS-DOS or Microsoft Windows, nor do the APIs of those systems use the character to denote the actual end of a file.
Some programming languages (e.g. Visual Basic) will not read past a "soft" EOF when using the built-in text file reading primitives (INPUT, LINE INPUT etc.), and alternate methods must be adopted, e.g. opening the file in binary mode or using the File System Object to progress beyond it.
Character 26 was used to mark "End of file" even if the ASCII calls it Substitute, and has other characters for this. Number 28 which is called "File Separator" has also been used for similar purposes.
In Unix operating systems, this character is typically used to suspend the currently executing interactive process. The suspended process can then be resumed in foreground (interactive) mode, or be made to resume execution in background mode, or be terminated. When entered by a user at their computer terminal, the currently running foreground process is sent a "terminal stop" (SIGTSTP) signal, which generally causes the process to suspend its execution. The user can later continue the process execution by using the "foreground" command (
fg) or the "background" command (
The Unicode Security Considerations report recommends this character as a safe replacement for unmappable characters during character set conversion.
In many GUIs and applications Control+Z (⌘ Command+Z on Mac OS) can be used to undo the last action. In many applications earlier actions than the last one can also be undone by pressing Control+Z multiple times. Control+Z was one of a handful of keyboard sequences chosen by the program designers at Xerox PARC to control text editing. Presumably these particular keystrokes were chosen because of their location on a standard QWERTY keyboard, since the Z (undo), X (cut), C (copy), and V (paste) keys are located together at the left end of the bottom row of the standard QWERTY keyboard.
- "Keyboard shortcuts for Windows". Microsoft Support. Microsoft. Retrieved 2 June 2012.
- John Elliott (1998). CP/M 1.4 disc formats. ()
- John Elliott (1998). CP/M 2.2 disc formats. ()
- John Elliott (1998). CP/M 3.1 disc formats. ()
- John Elliott (1998). CP/M 4.1 disc formats. ()
- CSV-1203 format specification Archived 2016-05-16 at the Portuguese Web Archive
- "Quick Reference: Unix Commands". IT Connect. University of Washington. Retrieved 2 June 2012.