Skip to content

Improve Unicode support and terminal-width policies - #99

Closed
reneleonhardt wants to merge 4 commits into
unicode-rs:masterfrom
reneleonhardt:feat/improve-unicode-support
Closed

reneleonhardt wants to merge 4 commits into
unicode-rs:masterfrom
reneleonhardt:feat/improve-unicode-support

Conversation

@reneleonhardt

@reneleonhardt reneleonhardt commented Oct 20, 2026 •

Copy link
Copy Markdown

Summary

  • Fix Unicode data parsing and prevent cached files from mixing Unicode releases.
  • Give canonical Hebrew forms equal widths. Make seven numerals correctly interrupt combining solidus overlays.
  • Document supported Unicode rules and existing variation-selector, emoji, and control-character policies.

Changes

  • Read property fields independently of comments and apply ordered @missing defaults before explicit values.
  • Compare both width and scanner state in normalization tests.
  • Reuse test buffers, remove debug output, and report missing benchmark data files.
  • Run generator tests and build documentation in both feature configurations in CI.
  • Add the default-off ascii-fast-path feature for ASCII-heavy workloads. CI tests it with and without CJK support.

Validation

  • Focused Rust tests pass with CJK and the ASCII fast path independently enabled and disabled.
  • Five generator tests, Clippy, formatting, and documentation builds with warnings as errors pass.
  • Regenerated Unicode 18.0 tables and emoji test data match the committed files.
  • Embedded ASCII, short Unicode, and mixed Unicode benchmarks pass with the ASCII feature enabled and disabled.

Performance

  • Forced lookup inlining reduced time by about 8–20% on selected long Unicode samples without the ASCII shortcut.
  • The measured scanner code grew by about 0.4–1.3 KB. Some tiny ASCII, CRLF, and mixed Unicode samples took about 0.2–0.7 ns longer.
  • The final commit adds ascii-fast-path. The default build omits every ASCII shortcut check.
  • With this feature, a 5,760-byte ASCII sample took about 20 times less time.
  • Enabling it added about 0.5–1.5 ns on sampled short Unicode and CRLF inputs. A 63-byte mixed label took about 5% longer.
  • Cargo combines features across dependencies. Another dependency can enable this feature for all callers. The iterator API bypasses the shortcut per call.
  • These measurements depend on the compiler, input, and calling context.

The Old Korean extension was rejected because no net benefit for common workloads was proven.

@reneleonhardt
reneleonhardt force-pushed the feat/improve-unicode-support branch 2 times, most recently from bec8ed6 to 16a9c95 Compare October 20, 2026 14:09
Read property fields independently of comments and apply ordered missing
defaults before explicit values. Validate cached Unicode releases.

Preserve the Lamed state for its canonical Hebrew presentation form and
exclude empty decompositions from solidus transparency. Add focused generator
and width regressions, and compare scanner states in normalization tests.
Name the Unicode rules and terminal policies used for width estimates.
Cover variation-selector and emoji fallbacks and build docs in both feature
configurations.

Reuse buffers and iterators in width tests, remove debug output, and fail
benchmarks when their input files are missing.
Force the generated lookup functions to inline and add representative long
and short Unicode benchmarks.

Paired comparisons measured about 8-20% less time on selected long Unicode
samples. Sample scanner code grew by about 0.4-1.3 KB. Some tiny ASCII, CRLF,
and mixed Unicode inputs took about 0.2-0.7 ns longer. Results depend on input
and calling context.
Gate the ASCII byte shortcut behind the default-off ascii-fast-path feature.
Remove the short-string cutoff, document feature unification and the iterator
bypass, and test both opt-in combinations in CI. Check the feature in MSRV CI.

The 5,760-byte ASCII sample took about 20 times less time with the feature.
Sampled short Unicode and CRLF inputs took about 0.5-1.5 ns longer, and a
63-byte mixed label took about 5% longer. Disabled builds omit these checks.
@reneleonhardt
reneleonhardt force-pushed the feat/improve-unicode-support branch from 16a9c95 to d10a502 Compare October 20, 2026 15:53
@Manishearth

Copy link
Copy Markdown
Member

This appears to be doing a ton of different changes with very little coherent story of what's going on. There's code cleanups mixed with docs changes mixed with behavior changes. Mixing behavior changes like this is just generally bad form in open source.

I don't have time to disentangle this. Separate well-scoped PRs might work, but also I don't really know what you're trying to do here.

If this was LLM done; please consider first talking to the maintainers about your desires and making sure we're on the same page. We have LLMs too; someone without any background on the crate proposing a pile of changes is strictly worse than us doing it ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants