unicode-segmentation

Split Rust strings into grapheme clusters, words, and sentences per Unicode UAX #29

Library
Cargo
v1.13.3
672stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity56
Maintenance16
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture78
Code Quality82
Innovation68
Learning Curve70

unicode-segmentation is a Rust crate maintained by the unicode-rs organization that implements the boundary-finding rules from Unicode Standard Annex #29. It provides iterators that split &str values into extended grapheme clusters, words, and sentences, handling the subtleties of combining marks, emoji modifier sequences, and locale-independent word/sentence punctuation correctly instead of naively iterating over chars.

Because text processing that only iterates over Rust chars (Unicode scalar values) frequently misrepresents what a human perceives as a single character, this crate is a foundational dependency across the Rust ecosystem — used by text editors, terminal emulators, formatters, and CLI tools that need accurate cursor movement, line wrapping, or word counting on arbitrary Unicode text.

What You Get

  • A graphemes(is_extended: bool) iterator that yields extended grapheme clusters (what users perceive as a single visual character, including combining marks and emoji ZWJ sequences)
  • unicode_words() and split_word_bounds() iterators for locale-independent word segmentation, including handling of apostrophes, numbers, and punctuation
  • unicode_sentences() for splitting text into sentence-like units per the Unicode sentence-boundary rules
  • A GraphemeCursor type supporting random-access and bidirectional boundary lookup for editors that need to move a cursor by one grapheme at a time
  • no_std compatibility (no libstd dependency) so it can be used in embedded and freestanding Rust contexts
  • Precompiled Unicode property tables (tables.rs) regenerated per Unicode release so behavior stays current with the latest Unicode Character Database

Common Use Cases

  • Text editors and terminal emulators computing correct cursor movement and line-wrapping across multi-codepoint emoji or accented characters
  • CLI tools and formatters that need accurate word or character counts for user-facing text (e.g. line-length limits, truncation with ellipsis)
  • String-processing libraries and parsers (e.g. syntax highlighters, diff tools) that need to iterate text in units a human would recognize as one character
  • Internationalized applications performing sentence or word splitting without pulling in a full ICU dependency

Under The Hood

Architecture: The crate is organized into four focused modules — grapheme.rs (extended grapheme cluster iteration and the GraphemeCursor random-access type), word.rs (word-boundary iteration with ASCII fast paths), sentence.rs (sentence-boundary iteration), and the large generated tables.rs (3,341 lines of Unicode property lookup tables), all tied together by a single UnicodeSegmentation trait defined in lib.rs that is implemented for &str. Boundary algorithms walk the string using state machines driven by property-class lookups rather than per-language rule sets, matching the UAX #29 specification directly. Tech Stack: Pure Rust, 2018 edition, MSRV 1.85.0, with zero runtime dependencies — dev-dependencies are limited to quickcheck, criterion, and proptest for testing/benchmarking only, and the crate has no_std support (no libstd requirement) via conditional compilation. Four Criterion benchmark suites (chars, words, word_bounds, unicode_word_indices) track performance regressions across releases. Code Quality: The tests/ directory includes a test.rs harness plus a testdata/ directory of official Unicode conformance test files, meaning correctness is validated against the same reference data Unicode publishes for UAX #29 compliance, not just hand-written unit tests; property-based tests via quickcheck/proptest add fuzzing-style coverage for edge cases like malformed or boundary-adjacent code points. API Design: The trait-based design lets consumers call .graphemes(true), .unicode_words(), etc. directly on any &str with a single use unicode_segmentation::UnicodeSegmentation; import, requiring no setup or configuration — an ergonomic, idiomatic-Rust extension-trait pattern that keeps the public surface minimal (four iterator methods plus the GraphemeCursor type) while doing this correctly is normally quite involved.

Used by 6 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
Rust
96%
Apache 2.0

InfluxDB

Databases · Analytics

31,705

Open-source time-series database built for real-time ingest, fast SQL queries, and embedded Python automation — powered by Apache Arrow and Parquet.

View details
86
Repo Health
76
Technical
72
Dependency
Built with
Rust96%
Updated yesterday
Rust
47%
MIT

Kuku

Note Taking

204

A local-first, open-source Markdown knowledge workspace for macOS — plain files, personal wiki and Second Brain workflows, AI-assisted diffs, and encrypted sync, built as an Obsidian alternative.

View details
73
Repo Health
67
Technical
68
Dependency
Built with
Rust47%
TypeScript40%
Updated 1 months ago
Rust
78%
AGPL 3.0

Lemmy

Community · Social Media

14,555

Federated, self-hosted Reddit alternative with full community ownership and no corporate control.

View details
90
Repo Health
74
Technical
63
Dependency
Built with
Rust78%
PLpgSQL14%
Updated yesterday
Rust
87%
AGPL 3.0

ParadeDB

Search · Databases · Analytics

9,175

Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.

View details
88
Repo Health
87
Technical
71
Dependency
Built with
Rust87%
PLpgSQL12%
Updated today
Rust
97%
MPL 2.0

Sonic

Databases · Search

21,315

Fast, lightweight, schema-less search backend in Rust — microsecond queries, 30MB RAM, no document storage required.

View details
88
Repo Health
88
Technical
73
Dependency
Built with
Rust97%
Updated 3 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search