Kelly Mears

Character Encoding

The mapping between characters and bytes, and the source of a specific family of invisible bugs.

Systems & Tooling2 min read224 words15 out · 24 in
also calledUnicodeUTF-8

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 recognize: 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. Normalization 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 also13

Glob

Wildcard pattern matching over filenames, similar enough to regular expressions to mislead.

Systems & Tooling12 connections

Token

The sub-word unit a language model actually reads and writes; the unit of cost and of context.

Agents & Language Models22 connections

Shell

The interactive command interpreter, and a programming language with unusually sharp edges.

Systems & Tooling24 connections

Vacuous Truth

A statement that holds only because its subject set is empty — a green result that measured nothing.

Method26 connections

Truncation Bias

Reading a truncated result as if it were the whole result, so every counterexample is invisible.

Method28 connections

Ground Truth

The measurement that arbitrates, as opposed to the artifact that merely reports.

Method99 connections

Falsifiability

A claim is only worth something if you know what observation would refute it.

Method47 connections

Coverage Gate

A build check that fails when coverage falls below a threshold, and what that pressure produces.

Testing & Verification16 connections

ANSI Escape Code

The in-band byte sequences, starting with the escape character, that tell a terminal to move the cursor, change color, or clear the screen, inherited from 1970s video terminals and still how every command-line tool draws.

Systems & Tooling12 connections

Emoji

Picture characters encoded in Unicode, born on Japanese phones in the late 1990s, drawn differently by every platform, and built from sequences of code points that break naive string handling.

Design & Interface9 connections

Text Truncation

Cutting text that doesn't fit and marking the cut with an ellipsis, a layout convenience that hides information, breaks in other languages, and needs care to stay accessible.

Design & Interface8 connections

Input Method

The software layer that turns keystrokes into text for writing systems with far more characters than a keyboard has keys, such as Chinese, Japanese and Korean, by letting people type sounds or shapes and choose from candidates.

Systems & Tooling8 connections

Base64

A way to write arbitrary bytes using 64 safe text characters, so binary data can travel through email, JSON, URLs, and other channels built for text, at the cost of a third more size and with no secrecy at all.

Data & Content8 connections

Linked from24