7 releases

0.1.5 Jul 25, 2023
0.1.4 Sep 29, 2022
0.1.2 Jul 25, 2021
0.1.1 Jan 30, 2021
0.0.1 Dec 10, 2018

#31 in Internationalization (i18n)

Download history 435789/week @ 2024-12-16 195154/week @ 2024-12-23 268496/week @ 2024-12-30 483022/week @ 2025-01-06 511068/week @ 2025-01-13 425161/week @ 2025-01-20 448656/week @ 2025-01-27 488419/week @ 2025-02-03 511253/week @ 2025-02-10 507984/week @ 2025-02-17 569269/week @ 2025-02-24 572496/week @ 2025-03-03 590137/week @ 2025-03-10 573421/week @ 2025-03-17 563522/week @ 2025-03-24 557746/week @ 2025-03-31

2,312,211 downloads per month
Used in 1,225 crates (12 directly)

Apache-2.0

79KB
159 lines

unicode-linebreak

Implementation of the Line Breaking Algorithm described in Unicode Standard Annex #14.

test Documentation

Given an input text, locates "line break opportunities", or positions appropriate for wrapping lines when displaying text.

Example

use unicode_linebreak::{linebreaks, BreakOpportunity::{Mandatory, Allowed}};

let text = "a b \nc";
assert!(linebreaks(text).eq([
	(2, Allowed),   // May break after first space
	(5, Mandatory), // Must break after line feed
	(6, Mandatory)  // Must break at end of text, so that there always is at least one LB
]));

Development

After cloning the repository or modifying LineBreak.txt the tables have to be (re-)generated:

# Generate src/tables.rs
(cd gen-tables && cargo run)
# Run tests to make sure it was successful
cargo test

No runtime deps