Two public-domain classics, one converter page: measure the whole-book ledger first
The two public-domain classics TXT volumes already listed on the site, Dongjing Menghualu and Huainanzi, are whole plain-text books: the first runs 100985 bytes, the second 476354 bytes. This article walks two tracks: a pure Node pass scans the whole books for bytes, code units, code points, code-point distribution and the count of characters above 65535; then the whole book and a slice are fed into the escape and restore functions of the Chinese-to-Unicode conversion page itself, watching the inflation ratio across four presets, the surrogate-pair branch and whole-book round-trip equality. The yardsticks are fs.statSync and charCodeAt throughout.
| Yardstick | Dongjing Menghualu | Huainanzi |
|---|---|---|
| Bytes | 100985 | 476354 |
| UTF-16 code units | 33955 | 159564 |
| Code points | 33954 | 159510 |
| Effective lines split on LF | 391 | 1019 |
| Characters after removing all whitespace | 33559 | 158491 |
| Characters above 65535 | 1 spot | 54 spots |
The first three bytes of both files are 227, 128, 144 — that is the UTF-8 of the opening bracket of a volume heading, not a BOM; zero CR characters, zero replacement characters. The code-unit counts exceed the code-point counts by exactly 1 and 54, matching the number of characters above 65535. The KiB-style display figures on the listing page serve only as a cross-check; this article quotes raw file bytes everywhere.
Code-point distribution: nine out of ten land in three zones
Of the 33954 code points in Dongjing Menghualu, 27603 are CJK basic-block ideographs at 81.30%, full-width forms take 3015 at 8.88%, CJK punctuation 2838 at 8.36%, and only 46 remain on the ASCII side. Huainanzi: 130957 basic ideographs at 82.10%, 19282 full-width forms at 12.09%, 7964 CJK punctuation at 4.99%, 94 on the ASCII side. The full stop U+3002 counts 1187 in one book and 5871 in the other.
Beyond the basic block: 1 spot and 54 spots
The yardstick scans every character of the whole book by code point, merging surrogate pairs before the code-point test. Dongjing Menghualu hits 1 spot, U+2686F (code-unit index 12694), plus 2 in Extension A (U+4B45, U+4986), and 0 in the compatibility block. Huainanzi hits 54 spots across 41 distinct code points, the earliest three crowded onto the same line, the highest seen U+29247, with another 24 in Extension A. Such rare characters are referenced by code point only, never pasted.
Figure 1: the same whole book through four presets, ratios spread from 4.9720 to 7.9504
Which branch does a value above 65535 take
Built on the spot with String.fromCodePoint(0x20BB7) (code units 0xD842 and 0xDFB7): both hex presets split it into two 4-digit forms, \ud842\udfb7, 12 characters in total; the dec preset emits ��, 16 characters; the hex-css preset emits \d842\udfb7, 10 characters — neither a 6-digit form nor a passthrough. On the restore side this goes down the first regex, which takes 4 digits twice and rejoins the 2 code units, code point still U+20BB7. A hand-written 7-character \u20bb7 gets its greedy 6 digits filled, reduced modulo 65536, and silently becomes U+0BB7; the malformed \uD84x matches none of the four regexes and stays in place.
Whole-book round trip: zero mismatches in one book, 90334 shifts in the other
Escape, then restore, and compare code unit by code unit against the original string. On the default preset Dongjing Menghualu's 201535-character escape string restores to 33955 code units, every position equal, 0 mismatches; hex/all (203730) and dec/non-ascii (268511) likewise match. Huainanzi's default-preset product of 951809 characters only restores to 159563 code units, one short, with 90334 mismatched code units, the first mismatch sitting at code-unit index 68870: the original there is U+6034 immediately followed by an uppercase letter A, and it comes back as U+034A — the {4,6} in the first regex /\u([0-9a-fA-F]{4,6})/ swallowed that A as a 5th digit. Rerunning with hex/all (957384 characters) or dec/non-ascii restores every position. The hex-css preset conserves nothing in either book: 168019 characters return only 33757 code units, first mismatch at index 4; 793360 characters return 159012, first mismatch at index 3, the swallowed character being the space inside 「卷一 原道训」.
Figure 2: a lone letter A absorbed into the hexadecimal digits, misaligning the book from there on
The mixed sample: who never enters escaping at all
All 10 code units of the sample are built from code points (U+0030 up to U+4E2D). The default preset yields 25 characters: the first 7 ASCII ones pass through at 1 character each, the full-width comma becomes \uff0c, the full stop \u3002, the ideograph \u4e2d, 6 characters each, and restore returns the same 10 code units; the hex/all preset converts all 10, 60 characters; dec/non-ascii gives 31 characters; hex-css gives 22. So digits, half-width punctuation, space and newline stay untouched under the non-ascii-only presets, while full-width marks and ideographs are escaped together; and a CSS-form product followed by whitespace loses that whitespace on restore.
Long-input timing and limits
Dongjing Menghualu: escaping 33955 code units takes 2.78 ms, restoring 201535 characters takes 24.42 ms; Huainanzi: escaping 159564 code units takes 11.80 ms, restoring 951809 characters takes 116.65 ms. The slice(0,100000) cut escapes into 596230 characters in 8.02 ms and restores to 99999 code units in 68.50 ms, with 31029 mismatched code units and the first mismatch still at 68870. Push to 1000000 code units: the escape product runs 5964205 characters, escaping takes 129.90 ms, restoring 776.77 ms, with no exception thrown and no truncation. The page script holds no length branch, no cap, no try/catch, and no silent ceiling.
Facts you can verify on the two entries
Both records are live, each with 2 download channels in state 1; the detail-page slugs are dongjing-menghualu and huainanzi, one slug shared across the three languages. Structure counts: within its 391 effective lines Dongjing Menghualu holds 97 standalone title lines and 10 volume headings, matching its ten volumes; Huainanzi holds 28 title lines and 21 volume headings across 1019 lines, running from 【卷一 原道训】 to 【卷二十一 要略】. Clean sample lines are limited to 【东都外城】 and 【宣德楼前省府宫宇】 as glyph evidence.
The entry pages live at Dongjing Menghualu and Huainanzi.
Frequently asked questions
Q: Will a whole book be silently truncated?
No. A 1000000-code-unit input escapes into 5964205 characters and restores in 776.77 ms, with no exception and no cut.
Q: Does an escape string always restore verbatim?
Not guaranteed. Huainanzi's default preset misaligns 90334 code units and returns 1 short; only hex/all restores position by position. Dongjing Menghualu happens to lack those neighbouring characters, so everything matches.
Q: What does a rare character outside the basic block turn into?
It splits into the pair of 4-digit forms, U+20BB7 becomes \ud842\udfb7, and it rejoins exactly.
Q: Can the listing sizes be quoted directly?
Those are KiB-display values; the 100985 and 476354 bytes here come from raw fs.statSync reads.
To rerun the whole-book ledger yourself, the entry point is the Unicode Converter page.