Crate unicode_normalization [] [src]

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.7"

Modules

char

Methods for composing and decomposing characters.

Structs

Decompositions

External iterator for a string decomposition's characters.

Recompositions

External iterator for a string recomposition's characters.

StreamSafe

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

IsNormalized

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

UNICODE_VERSION

Traits

UnicodeNormalization

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

Functions

is_nfc

Authoritatively check if a string is in NFC.

is_nfc_quick

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.

is_nfc_stream_safe

Authoritatively check if a string is Stream-Safe NFC.

is_nfc_stream_safe_quick

Quickly check if a string is Stream-Safe NFC.

is_nfd

Authoritatively check if a string is in NFD.

is_nfd_quick

Quickly check if a string is in NFD.

is_nfd_stream_safe

Authoritatively check if a string is Stream-Safe NFD.

is_nfd_stream_safe_quick

Quickly check if a string is Stream-Safe NFD.