The Question Comes From the Resource Page's Own FAQ
The detail page of that simplified TXT raises a question by itself: "Q: does the Thousand Character Classic really use one thousand characters with no repeats?" The answer printed under it is "the traditional wording is roughly one thousand non-repeating characters", and it adds that counts differ by edition and by character standard. That claim is itself measurable: how many is roughly one thousand, and non-repeating against what. I took the file as the text under test, read all eight boxes back, and chased every difference line by line.
The resource ships a simplified edition, so every sample glyph and quoted verse below keeps its simplified shape inside a Chinese-tagged span: that is the counted object, not the language of this article.
Measured: 4212 bytes, 139 physical lines, no BOM, LF endings, the final line terminated; the Thousand Character Classic (千字文) is laid out as title line L1, blank line L2, body lines L3 to L127 which is 125 lines, blank line L128, and a note block on L129 to L139. Some 122 of those body lines are four characters plus one full-width space plus four characters, while 3 other lines (L93, L102, L109) carry characters outside the range. The Word Count page holds a single textarea and eight statistic cards, and countText() is nothing but eight expressions, zero buttons, zero network calls.
One Run on the Whole File: What Each Box Reports
Paste the whole file, title line and note block included, and read the eight boxes back; then run only the body slice L3 to L127.
| Box | Whole file | Poem body |
|---|---|---|
| Total characters | 1528 | 1251 |
| Chinese characters | 1132 | 996 |
| English words | 8 | 0 |
| Number groups | 2 | 0 |
| Lines | 140 | 125 |
| Paragraphs | 3 | 1 |
| Spaces | 4 | 0 |
| Characters without spaces | 1260 | 1002 |
One Thousand Distinct Characters? 1000, 996, 995, 991
125 lines times 8 characters per line is 1000, but that is only the layout's arithmetic; widen the character range and recount one by one and the body measures exactly 1000 real Han characters. The page's own [\u4e00-\u9fa5] ([一-龥], U+4E00 to U+9FA5) reports only 996 on the same body, a gap of 4. De-duplication is the second ledger: 1000 leaves 995 once the repeats are dropped, and those 5 are exactly the 5 glyphs that each appear 2 times — 并 (L79, L119), 发 (L15, L21), 巨 (L9, L82), 戚 (L96, L105) and 云 (L7, L80). Only the occurrence counts are reported here; whether a pair is one merger left by the script reform can only be settled against a traditional edition, and the resource page states that this edition carries no scholarly collation. The two errors also stack: de-duplicating under the page's own regex leaves 991. The whole-file ledger instead reports 1132 hits and 1020 distinct glyphs, and the widened range gives 1136 with 1024 distinct.
Figure 1: four numbers, each answering a different question
The 4 Characters Outside the Range
The missed list holds only 4 items and every one of them is locatable: on L109 "弦歌酒䜩 接杯举觞" the 䜩 is U+4729, and on L93 "两䟽见机 解组谁逼" the 䟽 is U+47FD, both inside Extension A (U+3400 to 4DBF); the other two sit on that same L102 and are given only as the code points U+2CA0E and U+214DC, which fall in a supplementary plane this article cannot write. On top of that, the L102 line counts as 11 in the total box while a typical verse line is 9; the whole file reads total 1528 but 1526 when recounted by code point, and the gap of 2 is those two characters each taking one extra unit, which is also the same 2 by which the body's nospace 1002 exceeds 1000. No character here falls between U+9FA6 and U+9FFF, so the range never covered them rather than losing them inside it.
The Space Box: 4 Against 125
The regex behind the spaces box is one literal space, that is U+0020: all 4 it reports sit on the permission line L137, the 125 body lines contribute 0, and not one of the 125 full-width spaces U+3000 between the verses enters that box. The two boxes do not acknowledge each other: feed only two U+3000 and spaces reports 0 while characters without spaces also reports 0, because the \s used by nospace does recognise it. The whole-file ledger closes: 1528 minus 1260 equals 268, which is 139 line breaks plus 125 U+3000 plus 4 half-width spaces.
Figure 2: the 268 that gets subtracted is built from three runs
The Line Ledger and the Paragraph Ledger
lines splits on the line break and counts the pieces: 139 physical lines report 140, because a terminated final line leaves one empty piece behind; the very same body without that final break reports 125, and adding one break moves it to 126 at once, not one character touched. paras trims first, then splits on blank lines: the whole file reports 3, and the block lengths 5, 1251 and 267 are the title line, the body and the note block, while 3 plus 996 plus 133 Chinese characters is the whole file's 1132; every break inside a block is single, so \n\s*\n never forms, and the note block alone returns 1 paragraph.
The 8 English Words and the 2 Number Groups Both Come From the Tail
The eight tokens are https, zh, wikisource, org, wiki, CC, BY and SA, and they land on the address at L136 and the permission line at L137; num takes "4.0" and splits it into 4 and 0 with \d+. Feeding "CC BY-SA 4.0" alone measures 12 characters and reports en 3, num 2 and 2 spaces. Across those 125 body lines en and num are both 0, so what these two boxes report has nothing to do with the poem.
Line by Line Summed Against One Whole-File Run: Five Equal, Three Distorted
Feed each line on its own, sum the eight boxes, and compare that with one whole-file run: total sums to 1389 against 1528, short by 139, because the breaks are cut away and then belong to no piece at all; lines comes out 137 against 140; paras comes out 137 against 3, since every non-empty piece becomes a paragraph of its own and the count inflates by 134. The five fields 1132, 8, 2, 4 and 1260 stay identical under both methods, because not one hit ever spans a line.
Scaled Up 1000 Times and Run Three Times
Copying the whole file 1000 times is 4212000 bytes, and a complete countText run three times takes 134.4374, 75.1041 and 75.9508 milliseconds, the first one including warm-up while the last two settle at 75; timed apart, the Han regex alone takes 59.5327 and the space-stripping replace alone takes 7.0938. On that large text all eight boxes still report in full, with 139001 lines and 2001 paragraphs, while the untouched whole file runs in only 0.1291. All of these are Node timings on the function lifted verbatim from the template; the browser-side refresh cost and the native behaviour of a textarea both remain unmeasured.
Page Copy Against the Eight Expressions
Judging the intro list and the tips against the code gives 11 judgements, 3 consistent, 3 in conflict and 5 partly consistent. The conflicts land right on the target: "Chinese characters: accurately counts the number of Chinese Han characters" misses 4 real Han characters in this file, a true value of 1000 against the page's 996; "number groups: counts the digit characters in the text" in fact counts runs of digits, so "4.0" reports 2; and the punctuation entry in the intro list has no matching box among the eight fields at all. "English words are split by spaces" does not match the code either: abc123def reports 0 and don't reports 2.
FAQ
Q: How many characters does this copy of the Thousand Character Classic have?
It depends on the ledger: the whole file gives 1528 and 1132, the body slice 1251 and 996, the widened range recounts 1000 and leaves 995 distinct, the page regex leaves 991. "Roughly one thousand" only makes sense with those four numbers read together.
Q: Why does the spaces box show only 4 when the verses clearly hold 125 separators?
Those 4 half-width ones all sit in the permission line at the tail. Between the verses the separators are full-width spaces U+3000, which a regex that accepts only U+0020 never reaches, while the \s of nospace does strip those 125 away together with the 139 line breaks.
Q: Do 并, 发, 巨, 戚 and 云 count as repeats, and will you rank them?
Inside this body each of them appears 2 times, which is exactly why de-duplication lands on 995 instead of 1000; this article reports the occurrence counts, ranks nothing, and makes no claim about simplified and traditional merging. For how a character count is usually defined there is an earlier note, how to count words and characters in a paper or a piece of copy.