#arabic #sentence #script #bidirectional #applications #dont #unicode

arabic_reshaper

Reconstruct Arabic sentences to be used in applications that doesn't support Arabic script

12 releases

0.4.2 Aug 16, 2023
0.4.1 Apr 17, 2021
0.4.0 Mar 25, 2021
0.3.1 Mar 17, 2021
0.1.6 Aug 9, 2018

#2 in #arabic

35 downloads per month
Used in rtl_reshaper_rs

MIT license

87KB
2K SLoC

Rust 2K SLoC // 0.1% comments INI 294 SLoC // 0.1% comments

arabic-reshaper-rs

Reconstruct Arabic sentences to be used in applications that don't support Arabic.

This crate is python-arabic-reshaper ported to rust.

Like python-arabic-reshaper it reshapes the letters, but it doesnt reverse the writing, the user is responsible for that: you can look at Unicode bidirectional algorithm or simply try reversing the characters orders and see if that works for you

Usage:

arabic_reshape:

Reshape letters

use arabic_reshaper::arabic_reshape;
let salam = "سلام";
println!("{}",arabic_reshape(salam));
//  سلام is now correctly reshaped but the letters are not reversed yet
// For simple cases we can  use chars().rev()
// For a more correct approach http://unicode.org/reports/tr9/ should be used (via https://docs.rs/unic_bidi crate for example)

Checkout the tests/bench directories for more examples.

Minimum Rust version

Starting version 0.4.0 the msrv is 1.51

CLI:

rtl_reshaper_rs is a CLI frontend available that reshapes and reorders stdin.

Todo:

  • document the code

Credits/More info:

Check the awesome original python version.

python-arabic-reshaper

No runtime deps