Debian Codegraph @

third_party/rust/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. See the [`sets`] module for more details.
13
14 APIs that return a [`CodePointMapData`] exist for certain enumerated properties. See the
15 [`maps`] module for more details.
16
17 ## Examples
18
19 ### Property data as `CodePointSetData`s
20
21 ```rust
22 use icu::properties::{maps, sets, GeneralCategory};
23
24 // A binary property as a `CodePointSetData`
25
26 assert!(sets::emoji().contains('🎃')); // U+1F383 JACK-O-LANTERN
27 assert!(!sets::emoji().contains('木')); // U+6728
28
29 // An individual enumerated property value as a `CodePointSetData`
30
31 let line_sep_data = maps::general_category()
32 .get_set_for_value(GeneralCategory::LineSeparator);
33 let line_sep = line_sep_data.as_borrowed();
34
35 assert!(line_sep.contains32(0x2028));
36 assert!(!line_sep.contains32(0x2029));
37 ```
38
39 ### Property data as `CodePointMapData`s
40
41 ```rust
42 use icu::properties::{maps, Script};
43
44 assert_eq!(maps::script().get('🎃'), Script::Common); // U+1F383 JACK-O-LANTERN
45 assert_eq!(maps::script().get('木'), Script::Han); // U+6728
46 ```
47
48 [`ICU4X`]: ../icu/index.html
49 [Unicode Properties]: https://unicode-org.github.io/icu/userguide/strings/properties.html
50 [`CodePointSetData`]: https://docs.rs/icu_properties/latest/icu_properties/sets/struct.CodePointSetData.html
51 [`CodePointMapData`]: https://docs.rs/icu_properties/latest/icu_properties/maps/struct.CodePointMapData.html
52 [`sets`]: https://docs.rs/icu_properties/latest/icu_properties/sets/
53
54 <!-- cargo-rdme end -->
55
56 ## More Information
57
58 For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).