in src/_Private/decode_html_entity.php [17:55]
function decode_html_entity(string $string): ?(string, string, string) {
if ($string[0] !== '&') {
return null;
}
$matches = Regex\first_match(
$string,
re"/^&(#[0-9]{1,8}|#X[0-9a-f]{1,8}|[a-z][a-z0-9]*);/i",
);
if ($matches is null) {
return null;
}
$match = $matches[0];
$table = get_html_entity_table();
$out = $table[$match] ?? null;
if ($out !== null) {
return tuple($match, $out, Str\strip_prefix($string, $match));
}
if ($match[1] !== '#') {
return null;
}
$out = \html_entity_decode(
$match,
/* HH_FIXME[4106] */ /* HH_FIXME[2049] */ \ENT_HTML5,
'UTF-8',
);
if ($out === $match) {
return null;
}
if ($out === "\000") {
$out = UNICODE_REPLACEMENT_CHARACTER;
} else if (!\mb_check_encoding($out, 'UTF-8')) {
$out = UNICODE_REPLACEMENT_CHARACTER;
}
return tuple($match, $out, Str\strip_prefix($string, $match));
}