Skip to main content

UnicodeNormalization

Trait UnicodeNormalization 

Source
pub trait UnicodeNormalization {
    // Required methods
    fn nfc(&self) -> Cow<'_, str>;
    fn nfd(&self) -> Cow<'_, str>;
    fn nfkc(&self) -> Cow<'_, str>;
    fn nfkd(&self) -> Cow<'_, str>;
    fn is_nfc(&self) -> bool;
    fn is_nfd(&self) -> bool;
    fn is_nfkc(&self) -> bool;
    fn is_nfkd(&self) -> bool;
}
Expand description

Convenience trait for normalizing &str slices.

All methods return Cow<'_, str>, which is Cow::Borrowed when the input is already in the target normalization form (zero allocation).

Required Methods§

Source

fn nfc(&self) -> Cow<'_, str>

Normalize to NFC (Canonical Decomposition, followed by Canonical Composition).

Source

fn nfd(&self) -> Cow<'_, str>

Normalize to NFD (Canonical Decomposition).

Source

fn nfkc(&self) -> Cow<'_, str>

Normalize to NFKC (Compatibility Decomposition, followed by Canonical Composition).

Source

fn nfkd(&self) -> Cow<'_, str>

Normalize to NFKD (Compatibility Decomposition).

Source

fn is_nfc(&self) -> bool

Check whether the string is already in NFC.

Source

fn is_nfd(&self) -> bool

Check whether the string is already in NFD.

Source

fn is_nfkc(&self) -> bool

Check whether the string is already in NFKC.

Source

fn is_nfkd(&self) -> bool

Check whether the string is already in NFKD.

Implementations on Foreign Types§

Source§

impl UnicodeNormalization for str

Source§

fn nfc(&self) -> Cow<'_, str>

Source§

fn nfd(&self) -> Cow<'_, str>

Source§

fn nfkc(&self) -> Cow<'_, str>

Source§

fn nfkd(&self) -> Cow<'_, str>

Source§

fn is_nfc(&self) -> bool

Source§

fn is_nfd(&self) -> bool

Source§

fn is_nfkc(&self) -> bool

Source§

fn is_nfkd(&self) -> bool

Implementors§