Character Encoding
The mapping between characters and bytes, and the source of a specific family of invisible bugs.
Character encoding is the correspondence between characters and their byte representation. Unicode assigns a code point to every character; UTF-8 encodes those code points as one to four bytes, is backward-compatible with ASCII, and has won.
Even with the encoding war settled, several distinctions still cause bugs. A code point is not a character a person would recognise: emoji with modifiers, and accented letters written as a base plus a combining mark, span several. So "length" has at least three meanings — bytes, code points, and grapheme clusters — and string operations that split or reverse text will produce nonsense if they use the wrong one. Normalisation matters too, since visually identical strings can differ in bytes.
The sharpest practical hazard is control characters, and particularly the null byte. A file containing a real null is still valid text to a compiler and a formatter, renders as innocuous whitespace in most viewers, and causes search tools to treat the file as binary and suppress all matches silently. A search that returns nothing therefore looks like an absent symbol rather than a corrupted file. Inspecting the bytes is the only way to see it. See Silent Failure.
Terminal alignment is a related concern: East Asian characters occupy two columns and combining marks occupy none, so column arithmetic must use display width. See Terminal User Interface.
See also4
Hand-picked in the note itself — the neighbours worth reading next.
Token
The sub-word unit a language model actually reads and writes; the unit of cost and of context.
Agents & Language Models13 connections
Shell
The interactive command interpreter, and a programming language with unusually sharp edges.
Systems & Tooling15 connections
Terminal User Interface
An interface rendered as text in a terminal, and the design conventions that make command-line tools humane.
Graphics & Games10 connections
Silent Failure
A failure that produces no signal, so the absence of an error reads as success.
Method44 connections
Related6
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from3
Notes elsewhere in the wiki that reach for this one.
- ShellSystems & Tooling
The interactive command interpreter, and a programming language with unusually sharp edges.
- Terminal User InterfaceGraphics & Games
An interface rendered as text in a terminal, and the design conventions that make command-line tools humane.
- TokenAgents & Language Models
The sub-word unit a language model actually reads and writes; the unit of cost and of context.