Expand description
intl — a pure-Rust, #![no_std] analog of ICU.
The crate is always #![no_std]. The Unicode layer and several locale
helpers need no allocator; the alloc feature enables the allocating APIs
(most formatters). UCD and CLDR data are compiled by an offline code
generator into committed tables — const fn match lookups for the Unicode
properties and embedded binary blobs for the CLDR data — so lookups allocate
nothing and need no runtime initialization.
Modules:
unicode— General_Category and predicates, scripts, East Asian Width, numeric values, case mapping/folding, normalization (UAX #15), collation (UTS #10), segmentation (UAX #29), line breaking (UAX #14), bidi (UAX #9), identifiers (UAX #31), confusables (UTS #39), IDNA (UTS #46). Property tables are gated by feature-selectable codepoint ranges.locale— BCP-47 parsing/canonicalization, likely-subtags maximize/minimize, negotiation. (alloc)plural— CLDR cardinal/ordinal plural categories.number— decimal / percent / currency formatting. (alloc)datetime— Gregorian date/time formatting (styles, skeletons), ISO-8601 I/O, date arithmetic, localized GMT offsets, Islamic/Persian rendering. (alloc)calendar— Gregorian / Islamic / Persian / Hebrew / Japanese / ISO-week date conversions.relative,list,unit,message— relative-time, list, measurement-unit, and MessageFormat formatting. (alloc)display— locale display names (language / region).
use intl::unicode::{general_category, GeneralCategory};
assert_eq!(general_category('A'), GeneralCategory::UppercaseLetter);Modules§
- calendar
- Calendar date conversions (
no_std, noalloc): the Julian Day Number as a pivot between the proleptic Gregorian, civil (tabular) Islamic, Persian (Solar Hijri), Hebrew, Chinese (lunisolar, 1900–2099), and Japanese-era calendars, plus the ISO-8601 week date and day of week. Pure integer arithmetic; only the Chinese calendar uses an embedded lunar table. - datetime
- Locale-aware date and time formatting (CLDR / UTS #35, Gregorian).
Requires the
allocfeature. - display
- Locale display names (CLDR / UTS #35): the name of a language or region as
written in a given display locale.
no_std, noalloc(results borrow from the embedded tables). - list
- Locale-aware list formatting (CLDR / UTS #35): joining items with the right
connectors, e.g.
"a, b, and c"(English “and”) or"a, b o c"(Spanish “or”). Requires theallocfeature. - locale
- BCP-47 / Unicode (UTS #35) locale identifiers.
- message
- A pragmatic subset of ICU MessageFormat (UTS #35 messages). Requires the
allocfeature. - number
- Locale-aware decimal and percent number formatting (CLDR / UTS #35).
Requires the
allocfeature. - plural
- CLDR plural rules (UTS #35): selecting the
PluralCategoryfor a number in a given language. The rules are compiled from CLDR into amatchby the offline codegen, so selection allocates nothing and needs no runtime parsing. - relative
- Locale-aware relative time formatting (CLDR / UTS #35): “in 3 days”,
“2 hours ago”, “yesterday”. Requires the
allocfeature. - spellout
- Spelling integers out in words via the CLDR rule-based number format (RBNF).
Requires the
allocfeature. Locale-driven (a curated set of locales), not hardcoded for any language. - timezone
- POSIX
TZ-string time zones (no_std, noalloc): parse a rule string like"PST8PDT,M3.2.0,M11.1.0/2"and compute the UTC offset for any local date using its standard/DST rules. This handles the current rules of a zone without the full IANA historical database. - translit
- Transliteration / transforms. Requires the
allocfeature. - unicode
- Unicode rune analysis driven by the official Unicode Character Database (UCD).
- unit
- Locale-aware measurement-unit formatting (CLDR / UTS #35): “5 kilometers”,
“3 hr”, “2,5 Stunden”. Requires the
allocfeature.