• Home
Name Date Size #Lines LOC

..--

benches/04-Jul-2025-587442

examples/04-Jul-2025-7343

src/04-Jul-2025-9,4524,904

tests/04-Jul-2025-1,3751,290

.android-checksum.jsonD04-Jul-20259.2 KiB11

.cargo-checksum.jsonD04-Jul-20258.8 KiB11

Android.bpD04-Jul-20251.3 KiB5248

Cargo.lockD04-Jul-202519 KiB743657

Cargo.tomlD04-Jul-20253 KiB163137

LICENSED04-Jul-20252.1 KiB4736

METADATAD04-Jul-2025442 1817

MODULE_LICENSE_UNICODE_3D04-Jul-20250

README.mdD04-Jul-20252 KiB5637

cargo_embargo.jsonD04-Jul-2025315 1616

icu4x_bionic_dep.bp.fragmentD04-Jul-202561 55

README.md

1# icu_locale_core [![crates.io](https://img.shields.io/crates/v/icu_locale_core)](https://crates.io/crates/icu_locale_core)
2
3<!-- cargo-rdme start -->
4
5Parsing, manipulating, and serializing Unicode Language and Locale Identifiers.
6
7This module is published as its own crate ([`icu_locale_core`](https://docs.rs/icu_locale_core/latest/icu_locale_core/))
8and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project.
9
10The module provides algorithms for parsing a string into a well-formed language or locale identifier
11as defined by [`UTS #35: Unicode LDML 3. Unicode Language and Locale Identifiers`]. Additionally
12the module provides [`preferences`] interface for operations on locale preferences and conversions
13from and to locale unicode extensions.
14
15[`Locale`] is the most common structure to use for storing information about a language,
16script, region, variants and extensions. In almost all cases, this struct should be used as the
17base unit for all locale management operations.
18
19[`LanguageIdentifier`] is a strict subset of [`Locale`] which can be useful in a narrow range of
20cases where [`Unicode Extensions`] are not relevant.
21
22If in doubt, use [`Locale`].
23
24## Examples
25
26```rust
27use icu::locale::Locale;
28use icu::locale::{
29    locale,
30    subtags::{language, region},
31};
32
33let mut loc: Locale = locale!("en-US");
34
35assert_eq!(loc.id.language, language!("en"));
36assert_eq!(loc.id.script, None);
37assert_eq!(loc.id.region, Some(region!("US")));
38assert_eq!(loc.id.variants.len(), 0);
39
40loc.id.region = Some(region!("GB"));
41
42assert_eq!(loc, locale!("en-GB"));
43```
44
45For more details, see [`Locale`] and [`LanguageIdentifier`].
46
47[`UTS #35: Unicode LDML 3. Unicode Language and Locale Identifiers`]: https://unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers
48[`ICU4X`]: ../icu/index.html
49[`Unicode Extensions`]: extensions
50
51<!-- cargo-rdme end -->
52
53## More Information
54
55For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).
56