[][src]Crate 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.

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",
  "ג",
  "ב",
  "א",
]);

Re-exports

pub use level::Level;
pub use level::LTR_LEVEL;
pub use level::RTL_LEVEL;

Modules

deprecated

This module holds deprecated assets only.

format_chars

Directional Formatting Characters

level

Bidi Embedding Level

Structs

BidiInfo

Bidi information of the text.

InitialInfo

Initial bidi information of the text.

IsolatingRunSequence

Output of isolating_run_sequences (steps X9-X10)

ParagraphInfo

Bidi information about a single paragraph

Enums

BidiClass

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

Constants

UNICODE_VERSION

The Unicode version of data

Functions

bidi_class

Find the BidiClass of a single char.

isolating_run_sequences

Compute the set of isolating run sequences.

level_runs

Finds the level runs in a paragraph.

not_removed_by_x9
removed_by_x9

Should this character be ignored in steps after X9?

Type Definitions

LevelRun

A maximal substring of characters with the same embedding level.