Control character
In computing and telecommunications, a control character is a code point in a character set (such as ASCII or Unicode) that does not represent a printable symbol but instead initiates, modifies, or terminates a control function, typically affecting the behavior of a device, a data stream, or a communication protocol.
History
Control characters originated in the early days of telegraphy and were later formalized in the ASCII standard (American Standard Code for Information Interchange) in the 1960s. The original telegraph systems used characters such as "line feed" and "carriage return" to control the movement of paper in teleprinters. ASCII reserved the first 32 code points (0–31, decimal) and the DEL code (127) for control functions, while later standards such as ISO/IEC 646 and Unicode extended this concept to include additional control sets like the C1 set (128–159 in ISO 8859 and Unicode).
C0 Control Characters (ASCII)
The ASCII control characters (code points 0–31) are collectively known as the C0 set. They are grouped by function:
- Transmission control (e.g., STX, ETX, ACK, NAK): Used to manage data flow, framing, and error detection in serial communication protocols.
- Format effectors (e.g., BS, HT, LF, FF, CR): Control the layout of text on output devices, such as moving the cursor, advancing paper, or inserting tabs.
- Information separators (e.g., FS, GS, RS, US): Used to delimit logical records or fields in data streams.
- Device control (e.g., DC1–DC4): Historically employed to turn attached peripherals on and off (e.g., DC1 for "XON", DC3 for "XOFF").
- Others: NUL (null character) for padding, BEL (bell) to produce an audible alert, and ESC to introduce escape sequences.
The DEL character (code 127) is considered a control character as well, originally used to delete a previously punched hole in paper tape.
C1 Control Characters
In extensions such as ISO/IEC 6429 (ECMA-48), the C1 control set occupies code points 128–159 (0x80–0x9F) in 8-bit character encodings. Unicode also reserves this range for control characters. Notable C1 codes include:
- IND (Index), NEL (Next Line): Analogues to line feed and newline.
- HTS (Horizontal Tab Set), VTS (Vertical Tab Set): Set tab stops.
- CSI (Control Sequence Introducer): Initiates ANSI escape sequences used in terminal control (e.g., cursor movement, color changes).
- SPA (Start of Protected Area), EPA (End of Protected Area): Used in word-processing and terminal emulation.
In Unicode, C1 characters are explicitly defined but are rarely used directly in modern text; they are often replaced by equivalent escape sequences or markup.
Control Characters in Unicode
Unicode preserves the C0 and C1 control characters for backward compatibility, but it also includes additional dedicated control-like characters such as:
- U+200B ZERO WIDTH SPACE: A formatting control that allows line breaks without visible spacing.
- U+200C ZERO WIDTH NON-JOINER: Prevents cursive joining in scripts like Arabic.
- U+FEFF BYTE ORDER MARK (BOM): Used at the start of a text stream to indicate byte order or encoding; also acts as a zero-width non-breaking space.
Unicode also defines ISO 14651/UCA controls for collation and directional formatting characters (e.g., U+202A LEFT-TO-RIGHT EMBEDDING) for bidirectional text. These are sometimes classified as "format characters" rather than traditional control characters.
Usage
Control characters are essential in many contexts:
- Terminal emulation: Escape sequences (starting with ESC) control cursor position, screen clearing, text attributes, and color.
- Serial communication: Protocols like XON/XOFF use DC1 and DC3 for flow control; ASCII ACK/NAK are used in error detection.
- Data delimiters: In formats such as CSV or log files, Information Separators (RS, GS, US) occasionally serve as field or record separators.
- Text processing: The line feed (LF, U+000A) and carriage return (CR, U+000D) define newlines in different operating systems (Unix vs. Windows vs. classic Mac OS).
- Punched tape and legacy media: NUL and DEL were used for padding and deletion in physical tape.
Examples of Common Control Characters
| Code (dec) | Name | Abbreviation | Typical Use |
|------------|---------------------------|--------------|--------------------------------------|
| 0 | Null | NUL | Padding, string terminator in C |
| 7 | Bell | BEL | Audible alert on terminals |
| 8 | Backspace | BS | Move cursor left one position |
| 9 | Horizontal Tab | HT | Advance to next tab stop |
| 10 | Line Feed | LF | Move cursor down one line (Unix newline) |
| 12 | Form Feed | FF | Eject page or clear screen |
| 13 | Carriage Return | CR | Return cursor to beginning of line |
| 26 | Substitute | SUB | End-of-file marker in some systems |
| 27 | Escape | ESC | Start escape sequence |
| 127 | Delete | DEL | Delete previous character; nothing in ASCII terminal |
Modern Context and Challenges
As computing evolved, many historical control functions became obsolete or absorbed into higher-level protocols. In modern software:
- Control characters are often displayed as visual placeholders (e.g.,
^Cfor ETX) or handled invisibly by user interfaces. - The distinction between "control" and "formatting" characters has blurred. For example, Unicode format characters like the soft hyphen (U+00AD) enable invisible line-breaking hints, while zero-width spaces influence word-breaking without any visible glyph.
- Security concerns arise when control characters are embedded in user-generated text (e.g., injected escape sequences in terminal emulators leading to "terminal injection" attacks).
- Some legacy control characters (e.g., the C1 set) are deprecated in favor of Unicode markup like directional overrides and explicit formatting tags.
Despite their declining visibility, control characters remain a fundamental part of character encoding standards and continue to be used in system-level programming, text protocols, and internationalized text processing.
관심 있을 만한 문서
달(Moon)
달(영어: Moon)은 지구의 유일한 자연 위성이자 태양계에서 다섯 번째로 큰 위성으로, 지구로부터 평균 약 384,400 km 거리에서 공전한다. 달은 지구의 밤하늘에서 가장 밝고 큰 천체로서, 지구의 조석 현상과...
DeepSeek
DeepSeek(딥시크, 공식 명칭: 항저우 딥시크 인공지능 기초기술 연구 유한공사, 중국어: 杭州深度求索人工智能基础技术研究有限公司, '심원한 탐구'라는 뜻)는 대규모 언어 모델 및 관련 인공지능 기술을 개발하는 중...
퀴리(Ci)
퀴리(curie, 기호: Ci)는 방사능의 세기를 나타내는 비(非)SI 단위로, 방사선 연구의 개척자인 프랑스의 물리학자 피에르 퀴리(Pierre Curie)와 마리 퀴리(Marie Curie) 부부의 업적을 기리기...
체스
체스(chess)는 8×8 격자로 배열된 64개의 흑백 격자 무늬 체스판 위에서 두 명의 플레이어가 각각 16개의 기물로 이루어진 부대를 지휘하여, 상대방의 킹을 체크메이트하는 것을 목표로 하는 2인용 전략 보드게임...
댓글 (0)
아직 댓글이 없습니다. 첫 댓글을 남겨보세요!