1 unstable release

0.4.0 Nov 2, 2021

#23 in #cldr


Used in 3 crates

Custom license

1.5MB
9K SLoC

icu_properties crates.io

icu_properties is one of the ICU4X components.

This component provides definitions of Unicode Properties and APIs for retrieving property data in an appropriate data structure.

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

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

Examples

Property data as UnicodeSets

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

let provider = icu_testdata::get_provider();

// A binary property as a `UnicodeSet`

let payload =
    sets::get_emoji(&provider)
        .expect("The data should be valid");
let data_struct = payload.get();
let emoji = &data_struct.inv_list;

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

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

let payload =
    sets::get_for_general_category(&provider, GeneralCategory::LineSeparator)
        .expect("The data should be valid");
let data_struct = payload.get();
let line_sep = &data_struct.inv_list;

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

Property data as CodePointTries

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

let provider = icu_testdata::get_provider();

let payload =
    maps::get_script(&provider)
        .expect("The data should be valid");
let data_struct = payload.get();
let script = &data_struct.code_point_trie;

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

More Information

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

Dependencies

a