4 releases (2 breaking)

new 1.0.0-beta1 Aug 5, 2022
0.6.0 May 17, 2022
0.5.0 Jan 31, 2022
0.4.0 Nov 2, 2021

#18 in #cldr

Download history 45/week @ 2022-04-20 84/week @ 2022-04-27 213/week @ 2022-05-04 198/week @ 2022-05-11 1050/week @ 2022-05-18 369/week @ 2022-05-25 411/week @ 2022-06-01 849/week @ 2022-06-08 1588/week @ 2022-06-15 1680/week @ 2022-06-22 2257/week @ 2022-06-29 2268/week @ 2022-07-06 1834/week @ 2022-07-13 2041/week @ 2022-07-20 4202/week @ 2022-07-27 2786/week @ 2022-08-03

11,403 downloads per month
Used in 9 crates (5 directly)

Unicode-DFS-2016

2MB
15K SLoC

icu_properties crates.io

Definitions of Unicode Properties and APIs for retrieving property data in an appropriate data structure.

This module is published as its own crate (icu_properties) and as part of the icu crate. See the latter for more details on the ICU4X project.

APIs that return a CodePointSetData exist for binary properties and certain enumerated properties. See the sets module for more details.

APIs that return a CodePointMapData exist for certain enumerated properties. See the [maps] module for more details.

Examples

Property data as CodePointSetDatas

use icu::properties::{maps, sets, GeneralCategory};

let provider = icu_testdata::get_provider();

// A binary property as a `CodePointSetData`

let data = sets::load_emoji(&provider).expect("The data should be valid");
let emoji = data.as_borrowed();

assert!(emoji.contains('🎃')); // U+1F383 JACK-O-LANTERN
assert!(!emoji.contains('')); // U+6728

// An individual enumerated property value as a `CodePointSetData`

let data = maps::load_general_category(&provider).expect("The data should be valid");
let gc = data.as_borrowed();
let line_sep_data = gc.get_set_for_value(GeneralCategory::LineSeparator);
let line_sep = line_sep_data.as_borrowed();

assert!(line_sep.contains_u32(0x2028));
assert!(!line_sep.contains_u32(0x2029));

Property data as CodePointMapDatas

use icu::properties::{maps, Script};

let provider = icu_testdata::get_provider();

let map = maps::load_script(&provider).expect("The data should be valid");
let script = map.as_borrowed();

assert_eq!(script.get('🎃'), Script::Common); // U+1F383 JACK-O-LANTERN
assert_eq!(script.get(''), Script::Han); // U+6728

More Information

For more information on development, authorship, contributing etc. please visit ICU4X home page.

Dependencies