#rtl #unicode #text #layout #bidi

unicode-bidi

Implementation of the Unicode Bidirectional Algorithm

18 releases

0.3.4 Jul 6, 2017
0.2.6 May 17, 2017
0.2.5 Feb 10, 2017
0.2.4 Dec 19, 2016
0.2.0 Jul 23, 2015

#4 in Text processing

Download history 29041/week @ 2018-05-27 34356/week @ 2018-06-03 36140/week @ 2018-06-10 32258/week @ 2018-06-17 34344/week @ 2018-06-24 34652/week @ 2018-07-01 33869/week @ 2018-07-08 36442/week @ 2018-07-15 38457/week @ 2018-07-22 34672/week @ 2018-07-29 38584/week @ 2018-08-05 36159/week @ 2018-08-12 34124/week @ 2018-08-19

125,525 downloads per month

unicode-bidi

This crate implements the Unicode Bidirectional Algorithm for display of mixed right-to-left and left-to-right text. It is written in safe Rust, compatible with the current stable release.

Documentation

Travis-CI AppVeyor


lib.rs:

This crate implements the Unicode Bidirectional Algorithm for display of mixed right-to-left and left-to-right text. It is written in safe Rust, compatible with the current stable release.

Example

use unicode_bidi::BidiInfo;

// This example text is defined using `concat!` because some browsers
// and text editors have trouble displaying bidi strings.
let text = concat![
  "א",
  "ב",
  "ג",
  "a",
  "b",
  "c",
];

// Resolve embedding levels within the text.  Pass `None` to detect the
// paragraph level automatically.
let bidi_info = BidiInfo::new(&text, None);

// This paragraph has embedding level 1 because its first strong character is RTL.
assert_eq!(bidi_info.paragraphs.len(), 1);
let para = &bidi_info.paragraphs[0];
assert_eq!(para.level.number(), 1);
assert_eq!(para.level.is_rtl(), true);

// Re-ordering is done after wrapping each paragraph into a sequence of
// lines. For this example, I'll just use a single line that spans the
// entire paragraph.
let line = para.range.clone();

let display = bidi_info.reorder_line(para, line);
assert_eq!(display, concat![
  "a",
  "b",
  "c",
  "ג",
  "ב",
  "א",
]);
MIT / Apache-2.0 license

Dependencies

Reverse deps