#localization #rust-library #persian-numbers #number-conversion

rsnum2persian

A Rust library for converting numbers to their Persian representation

1 unstable release

0.1.0 Nov 29, 2024

#97 in Internationalization (i18n)

Download history 98/week @ 2024-11-25 21/week @ 2024-12-02 8/week @ 2024-12-09

127 downloads per month

MIT license

7KB
82 lines

Num2Persian

A Rust library for converting numbers to their Persian representation.

Features

  • Converts numbers to Persian text.
  • Supports ordinal numbers (e.g., "fifth" in Persian).
  • Handles large numbers up to trillions.

Installation

Add the following to your Cargo.toml:

[dependencies]
rsnum2persian = "0.1.0"

Usage

use rsnum2persian;
fn main() {
    let mut level = 0;
    println!("{}", persian_number_converter::num_to_persian(5678, &mut level, false));
    // Output: پنج هزار و ششصد و هفتاد و هشت
}

Ordinal Numbers

use rsnum2persian;
fn main() {
    let mut level = 0;
    println!("{}", persian_number_converter::num_to_persian(5678, &mut level, true));
    // Output: پنج هزار و ششصد و هفتاد و هشتم
}

Running Examples

This library includes an example demonstrating its usage:

cargo run --example main

No runtime deps