Pasted from a document test values
Characters that arrive with text copied out of a word processor or a web page. 12 values, each with what it breaks and what a correct application does instead.
Type them one at a time with AltShiftN
in the palette, or take them all into a script with nkb emit pasted-from-word.
Typographic apostrophe
pasted-from-word/smart-apostrophe
O’Brien
O’Brien
- 7 graphemes
- 7 code points
- 9 bytes
- 7 UTF-16 units
- What it breaks
- The typographic apostrophe arrives with every paste and is a different character from the one on the keyboard; search never matches.
- What a correct application does
- Normalised on save, or both forms treated as equivalent by search.
Curly quotation marks
pasted-from-word/smart-quotes
“Jan”
“Jan”
- 5 graphemes
- 5 code points
- 9 bytes
- 5 UTF-16 units
- What it breaks
- Curly quotation marks break parsers, command construction and any comparison against the straight form.
- What a correct application does
- Accepted and stored; normalised before anything parses the value.
Em dash between words
pasted-from-word/em-dash
Jan—Kowalski
Jan — Kowalski
- 14 graphemes
- 14 code points
- 16 bytes
- 14 UTF-16 units
- What it breaks
- The long dash pasted from a document where a hyphen was expected; range parsing and code matching stop working.
- What a correct application does
- Normalised before parsing, or accepted as an equivalent separator.
Range with an en dash
pasted-from-word/en-dash-range
2020–2026
2020–2026
- 9 graphemes
- 9 code points
- 11 bytes
- 9 UTF-16 units
- What it breaks
- A range that looks correct and parses as a single unknown token.
- What a correct application does
- Same as above.
Non-breaking space from a document
pasted-from-word/nbsp-from-word
JanKowalski
Jan\u00A0Kowalski
- 1 space that is not an ordinary space
- 12 graphemes
- 12 code points
- 13 bytes
- 12 UTF-16 units
- What it breaks
- Text editors insert non-breaking spaces automatically; the value looks normal and never matches an exact search.
- What a correct application does
- Normalised to an ordinary space, or found by search regardless.
Soft hyphen inside a word
pasted-from-word/soft-hyphen-pasted
Kowalski
Kowal\u00ADski
- 1 soft hyphen
- 9 graphemes
- 9 code points
- 10 bytes
- 9 UTF-16 units
- What it breaks
- Optional hyphens survive copying and split a word invisibly in storage.
- What a correct application does
- Stripped on save, or preserved and revealed in the interface.
Ellipsis character
pasted-from-word/ellipsis-char
Jan…
Jan…
- 4 graphemes
- 4 code points
- 6 bytes
- 4 UTF-16 units
- What it breaks
- One character that looks like three dots; length limits and comparisons disagree with what the user sees.
- What a correct application does
- Counted as one character, or normalised to three dots consistently.
Bullet from a list
pasted-from-word/bullet-char
•punkt
• punkt
- 7 graphemes
- 7 code points
- 9 bytes
- 7 UTF-16 units
- What it breaks
- A bullet pasted from a list turns a value into something that renders as a list item elsewhere.
- What a correct application does
- Stored as text, without being interpreted as formatting.
Non-breaking hyphen in a code
pasted-from-word/nonbreaking-hyphen
123‑456
123‑456
- 7 graphemes
- 7 code points
- 9 bytes
- 7 UTF-16 units
- What it breaks
- A non-breaking hyphen inside a code; visually identical to the ordinary one, different everywhere else.
- What a correct application does
- Normalised before validation of the code.
Zero-width space from a web page
pasted-from-word/zero-width-from-web
JanKowalski
Jan\u200BKowalski
- 1 zero-width character
- 12 graphemes
- 12 code points
- 14 bytes
- 12 UTF-16 units
- What it breaks
- Web pages insert zero-width characters for layout; they arrive with the copied text and stay forever.
- What a correct application does
- Stripped on save, or revealed in the interface.
Everything a document pastes
pasted-from-word/multiple-typographic
“Jan”—O’Brien…
“Jan” — O’Brien…
- 16 graphemes
- 16 code points
- 26 bytes
- 16 UTF-16 units
- What it breaks
- Everything at once, as it actually arrives from a document.
- What a correct application does
- Round-trips unchanged, and is found by a search typed on a keyboard.
Trailing non-breaking space
pasted-from-word/trailing-nbsp
Kowalski
Kowalski\u00A0
- 1 space that is not an ordinary space
- 9 graphemes
- 9 code points
- 10 bytes
- 9 UTF-16 units
- What it breaks
- A non-breaking space at the end: invisible, not removed by ordinary trimming, and enough to break a comparison.
- What a correct application does
- Trimmed together with ordinary whitespace.