Debian Codegraph @

debian/rust-vendor/icu_normalizer/README.md

raw
1 # icu_normalizer [![crates.io](https://img.shields.io/crates/v/icu_normalizer)](https://crates.io/crates/icu_normalizer)
2
3 <!-- cargo-rdme start -->
4
5 Normalizing text into Unicode Normalization Forms.
6
7 This module is published as its own crate ([`icu_normalizer`](https://docs.rs/icu_normalizer/latest/icu_normalizer/))
8 and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project.
9
10 ## Functionality
11
12 The top level of the crate provides normalization of input into the four normalization forms defined in [UAX #15: Unicode
13 Normalization Forms](https://www.unicode.org/reports/tr15/): NFC, NFD, NFKC, and NFKD.
14
15 Three kinds of contiguous inputs are supported: known-well-formed UTF-8 (`&str`), potentially-not-well-formed UTF-8,
16 and potentially-not-well-formed UTF-16. Additionally, an iterator over `char` can be wrapped in a normalizing iterator.
17
18 The `uts46` module provides the combination of mapping and normalization operations for [UTS #46: Unicode IDNA
19 Compatibility Processing](https://www.unicode.org/reports/tr46/). This functionality is not meant to be used by
20 applications directly. Instead, it is meant as a building block for a full implementation of UTS #46, such as the
21 [`idna`](https://docs.rs/idna/latest/idna/) crate.
22
23 The `properties` module provides the non-recursive canonical decomposition operation on a per `char` basis and
24 the canonical compositon operation given two `char`s. It also provides access to the Canonical Combining Class
25 property. These operations are primarily meant for [HarfBuzz](https://harfbuzz.github.io/), the types
26 [`CanonicalComposition`](properties::CanonicalComposition), [`CanonicalDecomposition`](properties::CanonicalDecomposition),
27 and [`CanonicalCombiningClassMap`](properties::CanonicalCombiningClassMap) implement the [`harfbuzz_traits`] if
28 the `harfbuzz_traits` Cargo feature is enabled.
29
30 Notably, this normalizer does _not_ provide the normalization “quick check” that can result in “maybe” in
31 addition to “yes” and “no”. The normalization checks provided by this crate always give a definitive
32 non-“maybe” answer.
33
34 ## Examples
35
36 ```rust
37 let nfc = icu_normalizer::ComposingNormalizerBorrowed::new_nfc();
38 assert_eq!(nfc.normalize("a\u{0308}"), "ä");
39 assert!(nfc.is_normalized("ä"));
40
41 let nfd = icu_normalizer::DecomposingNormalizerBorrowed::new_nfd();
42 assert_eq!(nfd.normalize("ä"), "a\u{0308}");
43 assert!(!nfd.is_normalized("ä"));
44 ```
45
46 <!-- cargo-rdme end -->
47
48 ## More Information
49
50 For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).