[][src]Crate unic_bidi

UNIC — Unicode Bidirectional Algorithm

A component of unic: Unicode and Internationalization Crates for Rust.

This UNIC component implements algorithms from Unicode Standard Annex #9 - Unicode Bidirectional Algorithm, a.k.a. UBA, used 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 unic_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",
  "ג",
  "ב",
  "א",
]);

Re-exports

pub use crate::level::Level;

Modules

bidi_class

Unicode Bidi_Class Character Property.

format_chars

Directional Formatting Characters

level

Bidi Embedding Level

Structs

BidiInfo

Bidi information of the text

ParagraphInfo

Bidi information about a single paragraph

Enums

BidiClass

Represents the Unicode character Bidi_Class property, also known as the bidirectional character type.

BidiClassCategory

Represents Category of Unicode character Bidi_Class property, as demostrated under "Table 4. Bidirectional Character Types".

Constants

PKG_DESCRIPTION

UNIC component description.

PKG_NAME

UNIC component name.

PKG_VERSION

UNIC component version.

UNICODE_VERSION

The Unicode version of data

Type Definitions

LevelRun

A maximal substring of characters with the same embedding level.