Skip to main content

decode_numeric

Function decode_numeric 

Source
pub fn decode_numeric(digits: &str, is_hex: bool) -> Option<char>
Expand description

Decode a numeric character reference (&#123; or &#x1F600;).

Accepts the digits without &#, &#x, or the trailing ;. is_hex indicates whether the reference uses hexadecimal.

Returns None if the codepoint is not a valid Unicode scalar value or is a disallowed control character (per the HTML spec, U+0000 is replaced with U+FFFD).

ยงExamples

use fhp_core::entity::decode_numeric;

assert_eq!(decode_numeric("60", false), Some('<'));
assert_eq!(decode_numeric("3C", true), Some('<'));
assert_eq!(decode_numeric("0", false), Some('\u{FFFD}'));