Debian Codegraph @

debian/rust-vendor/icu_properties/README.md

raw
1 # icu_properties [![crates.io](https://img.shields.io/crates/v/icu_properties)](https://crates.io/crates/icu_properties)
2
3 <!-- cargo-rdme start -->
4
5 Definitions of [Unicode Properties] and APIs for
6 retrieving property data in an appropriate data structure.
7
8 This module is published as its own crate ([`icu_properties`](https://docs.rs/icu_properties/latest/icu_properties/))
9 and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project.
10
11 APIs that return a `CodePointSetData` exist for binary properties and certain enumerated
12 properties.
13
14 APIs that return a `CodePointMapData` exist for certain enumerated properties.
15
16 ## Examples
17
18 ### Property data as `CodePointSetData`s
19
20 ```rust
21 use icu::properties::{CodePointSetData, CodePointMapData};
22 use icu::properties::props::{GeneralCategory, Emoji};
23
24 // A binary property as a `CodePointSetData`
25
26 assert!(CodePointSetData::new::<Emoji>().contains('🎃')); // U+1F383 JACK-O-LANTERN
27 assert!(!CodePointSetData::new::<Emoji>().contains('木')); // U+6728
28
29 // An individual enumerated property value as a `CodePointSetData`
30
31 let line_sep_data = CodePointMapData::<GeneralCategory>::new()
32 .get_set_for_value(GeneralCategory::LineSeparator);
33 let line_sep = line_sep_data.as_borrowed();
34
35 assert!(line_sep.contains('\u{2028}'));
36 assert!(!line_sep.contains('\u{2029}'));
37 ```
38
39 ### Property data as `CodePointMapData`s
40
41 ```rust
42 use icu::properties::CodePointMapData;
43 use icu::properties::props::Script;
44
45 assert_eq!(CodePointMapData::<Script>::new().get('🎃'), Script::Common); // U+1F383 JACK-O-LANTERN
46 assert_eq!(CodePointMapData::<Script>::new().get('木'), Script::Han); // U+6728
47 ```
48
49 ## Harfbuzz
50
51 The `harfbuzz_traits` Cargo feature can be used to add implementations of the [`harfbuzz_traits`] to
52 `CodePointMap<GeneralCategory>`, `CodePointMap<BidiMirroringGlyph>`, and to enable the
53 [`script::HarfbuzzScriptData`] type.
54
55 [`ICU4X`]: ../icu/index.html
56 [Unicode Properties]: https://unicode-org.github.io/icu/userguide/strings/properties.html
57
58 <!-- cargo-rdme end -->
59
60 ## More Information
61
62 For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).