logo
Expand description

Unicode character composition and decomposition utilities as described in Unicode Standard Annex #15.

extern crate unicode_normalization;

use unicode_normalization::char::compose;
use unicode_normalization::UnicodeNormalization;

fn main() {
    assert_eq!(compose('A','\u{30a}'), Some('Å'));

    let s = "ÅΩ";
    let c = s.nfc().collect::<String>();
    assert_eq!(c, "ÅΩ");
}

crates.io

You can use this package in your project by adding the following to your Cargo.toml:

[dependencies]
unicode-normalization = "0.1.19"

Modules

Methods for composing and decomposing characters.

Structs

External iterator for a string decomposition’s characters.

External iterator for a string recomposition’s characters.

External iterator for replacements for a string’s characters.

UAX15-D4: This iterator keeps track of how many non-starters there have been since the last starter in NFKD and will emit a Combining Grapheme Joiner (U+034F) if the count exceeds 30.

Enums

The QuickCheck algorithm can quickly determine if a text is or isn’t normalized without any allocations in many cases, but it has to be able to return Maybe when a full decomposition and recomposition is necessary.

Constants

Traits

Methods for iterating over strings while applying Unicode normalizations as described in Unicode Standard Annex #15.

Functions

Authoritatively check if a string is in NFC.

Quickly check if a string is in NFC, potentially returning IsNormalized::Maybe if further checks are necessary. In this case a check like s.chars().nfc().eq(s.chars()) should suffice.

Authoritatively check if a string is Stream-Safe NFC.

Quickly check if a string is Stream-Safe NFC.

Authoritatively check if a string is in NFD.

Quickly check if a string is in NFD.

Authoritatively check if a string is Stream-Safe NFD.

Quickly check if a string is Stream-Safe NFD.

Authoritatively check if a string is in NFKC.

Quickly check if a string is in NFKC.

Authoritatively check if a string is in NFKD.

Quickly check if a string is in NFKD.