pub struct Unicode {
    pub keywords: Keywords,
    pub attributes: Attributes,
}
Expand description

Unicode Extensions provide information about user preferences in a given locale.

A list of Unicode BCP47 U Extensions as defined in Unicode Locale Identifier specification.

Unicode extensions provide subtags that specify language and/or locale-based behavior or refinements to language tags, according to work done by the Unicode Consortium. (See RFC 6067 for details).

Examples

use icu::locid::Locale;
use icu::locid::{
    extensions_unicode_key as key, extensions_unicode_value as value,
};

let loc: Locale =
    "de-u-hc-h12-ca-buddhist".parse().expect("Parsing failed.");

assert_eq!(
    loc.extensions.unicode.keywords.get(&key!("ca")),
    Some(&value!("buddhist"))
);

Fields

keywords: Keywords

The key-value pairs present in this locale extension, with each extension key subtag associated to its provided value subtag.

attributes: Attributes

A canonically ordered sequence of single standalone subtags for this locale extension.

Implementations

Returns a new empty map of Unicode extensions. Same as default(), but is const.

Examples
use icu::locid::extensions::unicode::Unicode;

assert_eq!(Unicode::new(), Unicode::default());

Returns true if there list of keywords and attributes is empty.

Examples
use icu::locid::Locale;

let loc: Locale = "en-US-u-foo".parse().expect("Parsing failed.");

assert!(!loc.extensions.unicode.is_empty());

Clears all Unicode extension keywords and attributes, effectively removing the Unicode extension.

Example
use icu::locid::Locale;

let mut loc: Locale =
    "und-t-mul-u-hello-ca-buddhist-hc-h12".parse().unwrap();
loc.extensions.unicode.clear();
assert_eq!(loc, "und-t-mul".parse().unwrap());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This trait is implemented for compatibility with fmt!. To create a string, [Writeable::write_to_string] is usually more efficient.

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Writes a string to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to_parts, and discards any Part annotations. Read more

Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more

Write bytes and Part annotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to, and doesn’t produce any Part annotations. Read more

Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Adds separators according to the given SeparatorPolicy. Read more

Inserts a comma every three digits from the right. Read more

Inserts a space every three digits from the right. Read more

Inserts a period every three digits from the right. Read more

Inserts an underscore every three digits from the right. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.