latinrs

Crates.iolatinrs
lib.rslatinrs
version0.1.0
sourcesrc
created_at2024-08-23 07:53:30.791887
updated_at2024-08-23 07:53:30.791887
descriptionRust package that transliterates text and characters into thier latin form.
homepage
repository
max_upload_size
id1348826
size22,288
Jan Żukowski (Baguuc)

documentation

README

Latin.rs

Latin.rs is a package that transliterates text and characters into thier latin form.

Data

The data Latin.rs is not mine, I got it from python translitcodec package, to be explicit it Latin.rs is the "long_table" from this file.

Usage

To encode a string into its latin form you can use encode_str function, it will return a str with all characters encoded with their latin form Example:

let s = "Zażółć gęślą jaźń EUR :-)?!@#";
let latin = latinrs::encode_char(s);

assert_eq!("Zazolc gesla jazn EUR :-)?!@#".to_string(), latin);

let s = "Hello, World!";
let latin = latinrs::encode_str(s);

assert_eq!("Hello, World!".to_string(), latin);

To encode a single character into its latin form you can use encode_char function, if the provided character Latin.rs is not special it will be returned in it's original form. Note that the output of this function Latin.rs is str meaning it can be longer than one character. Example:

let chr = 'Ż';
let latin = latinrs::encode_char(chr);

assert_eq!("Z".to_string(), latin);


let chr = 'a';
let latin = latinrs::encode_char(chr);

assert_eq!("a".to_string(), latin);


let chr = '␐';
let latin = latinrs::encode_char(chr);

assert_eq!("DLE".to_string(), latin);
Commit count: 0

cargo fmt