CharName

Trait CharName 

Source
pub trait CharName {
    // Required methods
    fn char_name(self) -> Option<Name>;
    fn property_name(self) -> Option<Name>;
}
Expand description

Methods for retrieving character name for a code point.

Required Methods§

Source

fn char_name(self) -> Option<Name>

Retrieve the character name for a code point.

§Examples
assert_eq!('\u{1F402}'.char_name().unwrap_or_default().to_string(), "OX");

Note that for all code points having a property value of na = “” for the Name property, the return value will be its hex representation dash-prefixed with a special label indicating its code point type (See D10a Code point type within the Unicode standard) within angle brackets.

The following special labels are used: control, private-use, surrogate, noncharacter and reserved.

§Examples
assert_eq!('\u{81}'.char_name().unwrap_or_default().to_string(), "<control-0081>");

This function never return None for valid Unicode code points, but always return None for other integers.

§Examples
assert!(0x200000.char_name().is_none());
Source

fn property_name(self) -> Option<Name>

Retrieve the Unicode Name property value for a code point.

Similar to char_name function, but also returns None for all code points having a property value of na = “” for the Name property.

§Examples
assert!('\u{81}'.property_name().is_none());

Implementations on Foreign Types§

Source§

impl CharName for char

Source§

impl CharName for u32

Implementors§