Notes › Tech Notes › 24 whitespace code points survive even with every box checked: a per-code-point truth table for text trimming

24 whitespace code points survive even with every box checked: a per-code-point truth table for text trimming

A 26-line whitespace code-point sample run through every checkbox: the space box alone only touches U+0020, 24 code points still survive when all boxes are on, 6 zero-width ones are never deleted, and merge-blank-lines only matches \n{3,}, so CRLF text stays untouched even at 5 newline groups.

Trimming spaces, measured, touched exactly one code point

The most persistent illusion in text cleanup runs like this: tick the remove-all-spaces box and everything that looks like a space disappears. To check that claim, I copied the template's process() verbatim into a plain Node script, built a 26-line sample whose every line reads A<CODEPOINT>B — one different whitespace or format code point wedged between the two letters — a string totalling 103 code units and 151 UTF-8 bytes, and ran the whole truth table one checkbox state at a time. The first cell already breaks the illusion: with only the space box on, 103 code units become 102, the stats bar reads 103,102,1, and the only deleted code point is U+0020; the other 25 survive exactly as they were. Measured against the regex literal that actually ships, the target is nothing but U+0020, so the plain-language promise of deleting all whitespace does not hold anywhere in this table.

Full-width to half-width is a rewrite, not a deletion

With only the full-width-space conversion box on, the length stays 103 → 103 and does not budge; the sole change is U+3000 being rewritten into U+0020. All five numbers on the stats bar are counted in UTF-16 code units, which is why a rewrite leaves the length untouched. On the same basis, feeding in a short string that contains a 4-byte emoji (the letter x, one emoji, the letter y) still displays raw characters = 4.

Every box on: 24 code points survive, and the 25 spaces all came from newlines

With all eight boxes ticked, of the 26 code points still 24 survive untouched; only U+0020 and U+3000 are cleaned away, the count of directly adjacent AB pairs is 2, and the stats bar reads 103,101,2. This is the single easiest causality in the article to misread. The output contains 25 copies of U+0020, and they are not original spaces that survived the process — the sample buried exactly one U+0020 from the start, while every other space on screen comes from 25 U+000A characters converted into spaces by the final newline step.

Survival of the 26-code-point sample under three checkbox states (26 code points total)26 survivespace box onlycut 126 survivefull-width conversion onlycut 024 surviveall boxes oncut 2

Figure 1: survival of the 26 sample code points under three checkbox states; the space box deletes one, the conversion box deletes none, and opening every box at once deletes two.

The trim-line ledger: 20 stripped at line starts, 20 at line ends, 20 + 6 = 26

The remove-leading-and-trailing-spaces option is nothing but a trim() call in the source. Measured, it strips 20 code points at line starts — covering U+00A0, U+1680, U+2000 through U+200A (11 of them), U+2028, U+2029, U+202F, U+205F, U+3000, U+FEFF — and it strips the same 20 at line ends. The sample holds 26 code points in all, 20 + 6 = 26, and the remainder are exactly the zero-width and format class: U+200B, U+200C, U+200D, U+2060, U+00AD, U+3164. Across the nine checkbox states (each single box, nothing selected, everything on) this class was deleted or rewritten not once, at the start of a line or the end. So do not expect trim to clear zero-width characters as a side effect; the two groups simply disagree on what whitespace means. If you need real per-line deletion or slicing, that belongs to a different kind of tool such as text line operations, outside the reach of this truth table.

Code point by checkbox state: the truth table

Code pointSpace box onlyFull-width conversion onlyTrim-line box onlyAll boxes on
U+0020deleteduntouchedstripped at line start or enddeleted
U+3000untouchedrewritten into a spacestripped at line start or enddeleted
U+00A0 class (with U+1680, U+2000 through U+200A, U+2028, U+2029, U+202F, U+205F, U+FEFF)untoucheduntouchedstripped at line start or enduntouched
U+200Buntoucheduntoucheduntoucheduntouched
U+200Cuntoucheduntoucheduntoucheduntouched
U+200Duntoucheduntoucheduntoucheduntouched
U+2060untoucheduntoucheduntoucheduntouched
U+00ADuntoucheduntoucheduntoucheduntouched
U+3164untoucheduntoucheduntoucheduntouched
U+000Auntoucheduntoucheduntouchedreplaced with a space
U+000Duntoucheduntoucheduntoucheduntouched (orphan remnant)

Blank lines and merged blank lines: one criterion only, \n{3,}

Running only the remove-blank-lines box over the same 26-line sample outputs 103 → 103 and keeps all 26 lines: this box filters whole lines and rewrites nothing inside them, so the line carrying a U+200B in the middle never qualifies as blank; stacked on top of other boxes, the blank-line stats still read 5,5,0,3,1. The merge-blank-lines box keys on \n{3,}: a run of two newlines gives replaced=0, while longer runs each give replaced=1, and every hit collapses down to exactly two newlines, no more and no fewer. Rewrite the same string with CRLF endings and even a long run still gives replaced=0 — the count trusts U+000A itself, and a paired \r\n never enters the pattern, so for Windows-newline text these two boxes amount to never having run. The practical lesson is narrow: a checkbox that looks dormant may simply be speaking a different newline dialect than your text. I covered the recommended order between blank-line cleanup and extra-space cleanup in an older note, cleaning blank lines and whitespace; neither side repeats the other.

replaced counts for merging blank lines · LF versus CRLF0LF group 21LF group 31LF group 41LF group 50CRLF counted up to 5to 2 newlines

Figure 2: under LF, a two-newline group reports nothing while the three, four, and five groups each report a hit; written with CRLF, even the largest group stays at zero.

An orphan U+000D: no box will delete it

Feed in a\rb and the output under all nine checkbox states equals the input; not one box touches it. Run a\r\nb\rc\nd with every box on and the result is a b\rc d, 8 code units down to 7, leaving a lone U+000D stranded inside the string. A paired carriage return gets carried off by the newline-related steps, but one standing on its own survives untouched all the way to the final step.

The box shown first in the interface only runs at step 5

The execution order is hard-coded in this page's source: fullwidth → html → tab → all-space → trim-line → empty-line → merge-empty → no-newline, eight steps in all, and the checkbox sitting first on the interface is not reached until step 5 — text trim walks every input through the same fixed sequence, so the order in which you tick boxes never changes the order in which they run. This article reports that one ordering fact and does not test pairwise swaps. Exporting process() wholesale into a plain Node script and running the full sweep — 6 inputs times 256 checkbox combinations, 1536 runs in total — produced output longer than input zero times, and the negative-value clamp behind the removed counter never fired once. The stats bar also counts UTF-16 code units end to end: for the same 26-code-point sample the code-unit count is 103 while the UTF-8 byte count is 151, so do not blend the two scales when reading any line above.

Q: Why are there more spaces in the output after turning every box on?

The sample buried only 1 U+0020, yet the output counts 25 of them — all of them come from 25 U+000A converted into spaces by the last step. Two code points were deleted, 25 new spaces were manufactured, and those are two separate accounts: the first is a subtraction, the second is a conversion, and collapsing them into one impression is exactly the illusion this article started from.

Q: Can trim sweep zero-width characters away too?

No. U+200B, U+200C, U+200D, U+2060, U+00AD, U+3164 are not among the 20 code points that trim strips, and across the nine checkbox states not one of them was deleted or rewritten.

Q: Why does merging blank lines do nothing to the text I pasted?

The criterion is \n{3,}, which only fires on three or more consecutive newlines; with a short run, replaced stays at zero. If your text uses CRLF endings, replaced stayed at zero in the measurement even for the longest run, because this pattern does not recognize \r\n.

📎 Related articles

Paste 133 Characters, Copy Out 149: Six Rewrites of Value Text in the JSON View 2026-11-23 A malformed URL into the parser page: example.com:80 is read as the protocol, and %e stops the segment table halfway 2026-11-21 Cron generator template button round trip: only 1 of 8 rebuilds word for word, and the previewer freezes the second on the wall clock 2026-11-21 Rejection sampling and the no-repeat cutoff: 60000 draws give chi-square 53.75, and ratio 0.05 is the switch point 2026-11-21 Is Pasted-Back SQL Byte-Identical After Formatting: 8 String Syntaxes Cross-Checked, 2 Unclosed Backticks Paired Silently 2026-11-20