Repository navigation
Evaluation: Handling more \p{No} (Number_Other) Unicode codepoints #40
Closed
jakeboone02
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
After adding superscript/subscript digit normalization (20 chars), the question is whether to extend coverage to more of the ~895
\p{No}(Number_Other) codepoints.\p{No}and\p{Nd}are mutually exclusive — no overlap.What
\p{No}contains (~895 chars)The library already covers the 40 chars (super/sub digits + Western vulgar fractions) that actually appear in real-world text input.
Candidate tiers
Tier 1 — Simple digit sets with 0–9 (~30 additional chars)
Problem: most remaining digit-like sets only cover 1–9 (no zero): Ethiopic, Rumi, Coptic Epact, Sinhala Archaic, Brahmi 1–9, Bhaiksuki 1–9. A number like "10" can't be composed without a zero glyph. Several of these scripts (Brahmi, Bhaiksuki) already have
\p{Nd}digits the library handles — the\p{No}variants are archaic/alternative forms.Tier 2 — Additional vulgar fractions (~88 chars)
Oriya (1/4, 1/2, 3/4, 1/16, 1/8, 3/16), Malayalam (down to 1/160), Tamil Supplement (down to 1/320), Tibetan half-digits, Meroitic twelfths, etc.
Problem: increasingly exotic denominators with no real-world input likelihood. Each fraction needs a hand-authored map entry.
Tier 3 — Enclosed/circled numerals (~174 chars)
Circled ①–⑳, parenthesized ⑴–⒇, period-suffixed ⒈–⒛, negative circled, double circled, dingbat variants, CJK circled/parenthesized. Values 0–50.
Problem: these represent list item markers and ordinals, not "quantities" in the library's sense. Values go up to 50, so they can't be treated as single digits — they'd need a completely different approach (direct value lookup → string insertion).
Tier 4 — Ancient additive systems (~106 chars)
Old Italic, Imperial Aramaic, Palmyrene, Nabataean, etc. Each is a Roman-numeral-style additive system.
Problem: each script would need its own sequence parser, like the existing
parseRomanNumerals. Massive complexity for zero practical demand.Assessment
Complexity / maintainability
\p{No}is a grab-bag, so a drift test would flag hundreds of unhandled chars\p{No}catch-all with filter\p{No}/\p{No}/guA blanket
\p{No}approach is impractical — the category is a grab-bag of unrelated things. Each sub-group needs bespoke handling. No algorithmic shortcut exists because the groups are semantically different (digits vs. fractions vs. additive-system tokens vs. enclosed numerals).A
\p{Nd}drift test works because every\p{Nd}block follows the same pattern (10 contiguous digits).\p{No}has no such uniformity — a drift test would either (a) enumerate the exact set you intend to handle (tautological) or (b) flag every new Unicode addition as a failure even if it's irrelevant (noisy).Performance
/[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g) is a 20-char character class. Expanding to ~50–80 chars has negligible regex performance impact — character class matching is O(1) per character in modern engines.normalizeDigits(the\p{Nd}handler) is efficient because it uses a 68-entry numeric array + binary search — ~550 bytes for 680+ characters. An equivalent approach isn't possible for\p{No}due to non-uniform semantics.Practical value
The super/sub digits were added because
format-quantityoutputs them — there's a concrete round-trip use case. For everything else:\p{Nd}digits already handled; the\p{No}fractions are archaic typographic forms.Recommendation
Do not expand
\p{No}coverage beyond superscript/subscript digits.The current 40 handled
\p{No}characters (20 super/sub digits + 20 vulgar fractions) cover the only real-world use cases. Every additional tier adds maintenance burden and bundle size for characters with no practical input likelihood. If a concrete use case emerges (e.g., a companion library starts outputting enclosed numerals), it can be added surgically at that point.The one possible exception: if enclosed circled digits ①–⑨ (just the single-digit values, 9 chars) are ever requested as a feature, they'd be cheap to add as a small map — but this should be demand-driven, not speculative.
All reactions