Function icu_properties::sets::load_for_ecma262
source ยท pub fn load_for_ecma262(
name: &str,
) -> Result<CodePointSetDataBorrowed<'static>, PropertiesError>
Expand description
Returns a type capable of looking up values for a property specified as a string, as long as it is a binary property listed in ECMA-262, using strict matching on the names in the spec.
This handles every property required by ECMA-262 /u
regular expressions, except for:
Script
andGeneral_Category
: handle these directly withmaps::load_general_category()
andmaps::load_script()
. using property values parsed viaGeneralCategory::get_name_to_enum_mapper()
andScript::get_name_to_enum_mapper()
if necessary.Script_Extensions
: handle this directly using APIs fromcrate::script
, likescript::load_script_with_extensions_unstable()
General_Category
mask values: Handle this alongsideGeneral_Category
usingGeneralCategoryGroup
, using property values parsed viaGeneralCategoryGroup::get_name_to_enum_mapper()
if necessaryAssigned
,All
, andASCII
pseudoproperties: Handle these using their equivalent sets:Any
can be expressed as the range[\u{0}-\u{10FFFF}]
Assigned
can be expressed as the inverse of the setgc=Cn
(i.e.,\P{gc=Cn}
).ASCII
can be expressed as the range[\u{0}-\u{7F}]
General_Category
property values can themselves be treated like properties using a shorthand in ECMA262, simply create the correspondingGeneralCategory
set.
โจ Enabled with the compiled_data
Cargo feature.
๐ Help choosing a constructor
use icu::properties::sets;
let emoji = sets::load_for_ecma262("Emoji").expect("loading data failed");
assert!(emoji.contains('๐ฅ')); // U+1F525 FIRE
assert!(!emoji.contains('V'));