Crate icu

source · []
Expand description

icu is the main meta-package of the ICU4X project.

It provides a comprehensive selection of Unicode Internationalization Components in their canonical configurations intended to enable software internationalization capabilities.

The package is provided for convenience and users are encouraged to fine-tune components with the features they need.

The package does not bring any unique functionality. Users can achieve the exact same by manually including the dependent components with pre-selected features.

Data Management

Most of Unicode functionality relies on data which has to be provided to the APIs.

ICU4X project uses a concept of DataProvider - a service used to handle data management.

There can be many different heuristics for handling data management and this meta-package does not supply any default DataProvider.

When using ICU4X users are expected to decide which provider they want to use and instrument it to point at the correct location where the data files are stored.

In the following examples an icu_testdata package is used which wraps an FsDataProvider with locally available subset of data.


ICU4X components share a set of common features that control whether core pieces of functionality are compiled. These features are:

  • serialize: Whether to include Serde Deserialize implementations for ICU4X locale data structs, such as SymbolsV1, and Serialize/Deserialize implementations for core libary types, such as Locale (On by default)
  • datagen: Whether to include Serde Serialize and other data generation traits for ICU4X locale data structs.
  • bench: Whether to enable exhaustive benchmarks. This can be enabled on individual crates when running cargo bench.
  • experimental: Whether to enable experimental preview features. Modules enabled with this feature may not be production-ready and could change at any time.


use icu::locid::locale;
use icu::datetime::{DateTimeFormat, options::length, mock::parse_gregorian_from_str};

let provider = icu_testdata::get_provider();

let options = length::Bag::from_date_time_style(length::Date::Long, length::Time::Medium).into();

let dtf = DateTimeFormat::try_new(locale!("en"), &provider, &options)
    .expect("Failed to create DateTimeFormat instance.");

let date = parse_gregorian_from_str("2020-09-12T12:35:00")
    .expect("Failed to parse date.");

let formatted_date = dtf.format(&date);
assert_eq!(formatted_date.to_string(), "September 12, 2020 at 12:35:00 PM");


Contains the core types used by ICU4X for dealing with dates, times, and custom calendars.

Date and Time operations

Decimal formatting operations

List formatting

This API provides functionality to canonicalize locale identifiers based upon CLDR data.

Language and Locale operations

Plural Rules operations

Unicode properties