https://github.com/xclud/rust-bidi
Implementation of the Unicode Bidi Algorithm (UBA).
https://github.com/xclud/rust-bidi
bidi bidirectional rust unicode
Last synced: 7 months ago
JSON representation
Implementation of the Unicode Bidi Algorithm (UBA).
- Host: GitHub
- URL: https://github.com/xclud/rust-bidi
- Owner: xclud
- Created: 2023-09-15T12:05:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-18T09:47:46.000Z (about 2 years ago)
- Last Synced: 2025-02-09T07:35:05.868Z (8 months ago)
- Topics: bidi, bidirectional, rust, unicode
- Language: Rust
- Homepage: https://crates.io/crates/bidi
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Implementation of the Unicode Bidirectional Algorithm (UBA).
Reference: [http://www.unicode.org/reports/tr9/](http://www.unicode.org/reports/tr9/).
Converts logical strings to their equivalent visual representation. Persian, Hebrew and Arabic languages (and any other RTL language) are supported.
```rust
#[test]
/// Shaping test.
fn shaping() {
let text: &str = "مهدی";
let mut text_u16 = text.encode_utf16().collect::>();perform_shaping(&mut text_u16);
let result = String::from_utf16(text_u16.as_slice()).unwrap();
assert_eq!(result, "ﻣﻬﺪﯼ");
assert_eq!(text_u16, vec!['ﻣ' as u16, 'ﻬ' as u16, 'ﺪ' as u16, 'ﯼ' as u16]);
}#[test]
/// Paragraph test.
fn paragraph() {
let text: &str = "Two\nParagraphs";
let text_u16 = text.encode_utf16().collect::>();let paragraphs = split_string_to_paragraphs(&text_u16);
assert_eq!(paragraphs.len(), 2);
assert_eq!(paragraphs[0].text, vec![84, 119, 111]);
}
```## Other Implementations
This package is also written in Dart (apart from this package, which is written in Rust). If you are looking for a pure Dart implementation of this package, look at [https://pub.dev/packages/bidi/](https://pub.dev/packages/bidi/).