icu_decimal
offers localized decimal number formatting.
Currently, icu_decimal
provides [FixedDecimalFormat
], which renders basic decimal numbers
in a locale-sensitive way.
Support for currencies, measurement units, and compact notation is planned. To track progress, follow icu4x#275.
```rust use icu::decimal::FixedDecimalFormat; use icu::locid::locale; use writeable::Writeable;
let provider = icutestdata::getprovider(); let fdf = FixedDecimalFormat::try_new(locale!("bn"), &provider, Default::default()) .expect("Data should load successfully");
let fixeddecimal = 1000007.into(); let formattedvalue = fdf.format(&fixeddecimal); let formattedstr = formattedvalue.writeto_string();
asserteq!("১০,০০,০০৭", formattedstr); ```
```rust use fixed_decimal::FixedDecimal; use icu::decimal::FixedDecimalFormat; use icu::locid::Locale; use writeable::Writeable;
let provider = icuprovider::inv::InvariantDataProvider; let fdf = FixedDecimalFormat::trynew(Locale::UND, &provider, Default::default()) .expect("Data should load successfully");
let fixeddecimal = FixedDecimal::from(200050) .multipliedpow10(-2) .expect("Operation is fully in range");
asserteq!("2,000.50", fdf.format(&fixeddecimal).writetostring()); ```
For more information on development, authorship, contributing etc. please visit ICU4X home page
.