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

#22 in Internationalization (i18n)

Download history 135609/week @ 2024-01-26 161930/week @ 2024-02-02 145096/week @ 2024-02-09 149429/week @ 2024-02-16 160353/week @ 2024-02-23 190989/week @ 2024-03-01 193806/week @ 2024-03-08 198483/week @ 2024-03-15 183593/week @ 2024-03-22 182369/week @ 2024-03-29 178705/week @ 2024-04-05 193708/week @ 2024-04-12 198157/week @ 2024-04-19 197693/week @ 2024-04-26 208978/week @ 2024-05-03 179904/week @ 2024-05-10

816,683 downloads per month
Used in 713 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