mgeisler / unicode-linebreak

๓ ผ๐Ÿ’” Implementation of the Unicode Line Breaking Algorithm in Rust

Home Page:https://crates.io/crates/unicode-linebreak

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
]));

About

๓ ผ๐Ÿ’” Implementation of the Unicode Line Breaking Algorithm in Rust

https://crates.io/crates/unicode-linebreak

License:Apache License 2.0


Languages

Language:Rust 100.0%