2 releases
0.0.2 | Jul 18, 2022 |
---|---|
0.0.1 | Jul 18, 2022 |
#241 in Value formatting
13KB
294 lines
Note it's my first crate, plz go easy on me!
whoa-german-numbers
parse textual german number formats in rust
Notably, numbers are not segmented by spaces or dashes in german - meaning they can be quite unruly sometimes.
Usage
extern crate whoa_german_numbers;
use whoa_german_numbers::{number_to_text, text_to_number};
let num = text_to_number("zwölf");
assert_eq!(num.unwrap(), 12);
let str = number_to_text(121);
assert_eq!(str, "einhunderteinundzwanzig");
*/
text_to_number - "fünf" -> 5
Convert written german numbers like "dreitausend" to integers (like 3000).
use whoa-german-numbers::text_to_number;
assert_eq!(text_to_number("fünf").unwrap(), 5);
assert_eq!(text_to_number("fünfte").unwrap(), 5); //ordinal support
assert_eq!(text_to_number("zweihundertzehn").unwrap(), 210);
number_to_text - 5 -> "fünf"
Convert an integer (like 81), into a german text number, like "einundachtzig".
use whoa-german-numbers::number_to_text;
assert_eq!(number_to_text(81), "einundachtzig");
assert_eq!(number_to_text(5), "fünf");
assert_eq!(number_to_text(131), "einhunderteinunddreißig");
MIT