[−][src]Module icu_locid::extensions
Unicode Extensions provide a mechanism to extend the LanguageIdentifier
with
additional bits of information - a combination of a LanguageIdentifier
and Extensions
is called Locale
.
There are four types of extensions:
Unicode Extensions
- marked asu
.Transform Extensions
- marked ast
.Private Use Extensions
- marked asx
.- Other extensions - marked as any
a-z
except ofu
,t
andx
.
One can think of extensions as a bag of extra information on top of basic 4 subtags
.
Notice: Other
extension type is currently not supported.
Examples
use icu_locid::Locale; use icu_locid::extensions::unicode::{Key, Value}; let loc: Locale = "en-US-u-ca-buddhist-t-en-US-h0-hybrid-x-foo".parse() .expect("Failed to parse."); assert_eq!(loc.language, "en"); assert_eq!(loc.script, None); assert_eq!(loc.region, Some("US".parse().unwrap())); assert_eq!(loc.variants.len(), 0); let key: Key = "ca".parse().expect("Parsing key failed."); let value: Value = "buddhist".parse().expect("Parsing value failed."); assert_eq!(loc.extensions.unicode.keywords.get(key), Some(&value));
Re-exports
pub use private::Private; |
pub use transform::Transform; |
pub use unicode::Unicode; |
Modules
private | Private Use Extensions is a list of extensions intended for private use. |
transform | Transform Extensions provide information on content transformations in a given locale. |
unicode | Unicode Extensions provide information about user preferences in a given locale. |
Structs
Extensions | A map of extensions associated with a given `Locale. |
Enums
ExtensionType | Defines the type of extension. |