Struct Unicode

struct Unicode { ... }

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::locale::extensions::unicode::{key, value};
use icu::locale::Locale;

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

impl Unicode

fn to_string(self: &Self) -> String

Converts the given value to a String.

Under the hood, this uses an efficient Writeable implementation. However, in order to avoid allocating a string, it is more efficient to use Writeable directly.

impl Unicode

const fn new() -> Self

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

Examples

use icu::locale::extensions::unicode::Unicode;

assert_eq!(Unicode::new(), Unicode::default());
fn is_empty(self: &Self) -> bool

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

Examples

use icu::locale::Locale;

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

assert!(!loc.extensions.unicode.is_empty());
fn clear(self: &mut Self)

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

Example

use icu::locale::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());
fn total_cmp(self: &Self, other: &Self) -> Ordering

Returns an ordering suitable for use in BTreeSet.

The ordering may or may not be equivalent to string ordering, and it may or may not be stable across ICU4X releases.

impl Clone for Unicode

fn clone(self: &Self) -> Unicode

impl Debug for Unicode

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Default for Unicode

fn default() -> Unicode

impl Display for Unicode

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for Unicode

impl Freeze for Unicode

impl Hash for Unicode

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl PartialEq for Unicode

fn eq(self: &Self, other: &Unicode) -> bool

impl RefUnwindSafe for Unicode

impl Send for Unicode

impl StructuralPartialEq for Unicode

impl Sync for Unicode

impl Unpin for Unicode

impl UnsafeUnpin for Unicode

impl UnwindSafe for Unicode

impl Writeable for Unicode

fn write_to<W: core::fmt::Write + ?Sized>(self: &Self, sink: &mut W) -> Result
fn writeable_length_hint(self: &Self) -> LengthHint

impl<T> Any for Unicode

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Unicode

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Unicode

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Unicode

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for Unicode

impl<T> From for Unicode

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Unicode

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Unicode

fn to_string(self: &Self) -> String

impl<T, U> Into for Unicode

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Unicode

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Unicode

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>