Crate icu_segmenter[][src]

Expand description

A line breaker that is compatible with Unicode Standard Annex #14 and CSS properties.

 use icu_segmenter::LineBreakIterator;

 let mut iter = LineBreakIterator::new("Hello World");
 let result: Vec<usize> = iter.collect();
 println!("{:?}", result);

With CSS property.

use icu_segmenter::{LineBreakIterator, LineBreakRule, WordBreakRule};

let iter = LineBreakIterator::new_with_break_rule(
    "Hello World",
    LineBreakRule::Strict,
    WordBreakRule::BreakAll,
    false,
);
let result: Vec<usize> = iter.collect();
println!("{:?}", result);

Use Latin 1 string for C binding and etc.

use icu_segmenter::LineBreakIteratorLatin1;

let s = "Hello World";
let iter = LineBreakIteratorLatin1::new(s.as_bytes());
let result: Vec<usize> = iter.collect();
println!("{:?}", result);

Generating property table

Copy the following files to tools directory. Then run ./generate_properties.py in tools directory (requires Python 3.8+). Machine generated files are moved to src directory.

Structs

The struct implementing the Iterator trait over the line break opportunities of the given string. Please see the module-level documentation for its usages.

The struct implementing the Iterator trait over the line break opportunities of the given string. Please see the module-level documentation for its usages.

The struct implementing the Iterator trait over the line break opportunities of the given string. Please see the module-level documentation for its usages.

Enums

An enum specifies the strictness of line-breaking rules. It can be passed as an argument when creating a line breaker.

An enum specifies the line break opportunities between letters. It can be passed as an argument when creating a line breaker.