API / Minn\Html / Decoder

Decoder final class

Minn\Html\Decoder · public/minn/src/Minn/Html/Decoder.php · 129 lines

Character reference decoding for text and attribute values: numeric and named references, the legacy names that work without a semicolon (not in an attribute when an "=" or alphanumeric follows), unknown ones left as is.

Uses 1

Constants and properties

privateLEGACY = array ( 0 => 'AElig', 1 => 'AMP', 2 => 'Aacute', 3 => 'Acirc', 4 => 'Agrave', 5 => 'Aring', 6 => 'Atilde', 7 => 'Auml', 8 => 'COPY', 9 => 'Ccedil', 10 => 'ETH', 11 => 'Eacute', 12 => 'Ecirc', 13 => 'Egrave', 14 => 'Euml', 15 => 'GT', 16 => 'Iacute', 17 => 'Icirc', 18 => 'Igrave', 19 => 'Iuml', 20 => 'LT', 21 => 'Ntilde', 22 => 'Oacute', 23 => 'Ocirc', 24 => 'Ograve', 25 => 'Oslash', 26 => 'Otilde', 27 => 'Ouml', 28 => 'QUOT', 29 => 'REG', 30 => 'THORN', 31 => 'Uacute', 32 => 'Ucirc', 33 => 'Ugrave', 34 => 'Uuml', 35 => 'Yacute', 36 => 'aacute', 37 => 'acirc', 38 => 'acute', 39 => 'aelig', 40 => 'agrave', 41 => 'amp', 42 => 'aring', 43 => 'atilde', 44 => 'auml', 45 => 'brvbar', 46 => 'ccedil', 47 => 'cedil', 48 => 'cent', 49 => 'copy', 50 => 'curren', 51 => 'deg', 52 => 'divide', 53 => 'eacute', 54 => 'ecirc', 55 => 'egrave', 56 => 'eth', 57 => 'euml', 58 => 'frac12', 59 => 'frac14', 60 => 'frac34', 61 => 'gt', 62 => 'iacute', 63 => 'icirc', 64 => 'iexcl', 65 => 'igrave', 66 => 'iquest', 67 => 'iuml', 68 => 'laquo', 69 => 'lt', 70 => 'macr', 71 => 'micro', 72 => 'middot', 73 => 'nbsp', 74 => 'not', 75 => 'ntilde', 76 => 'oacute', 77 => 'ocirc', 78 => 'ograve', 79 => 'ordf', 80 => 'ordm', 81 => 'oslash', 82 => 'otilde', 83 => 'ouml', 84 => 'para', 85 => 'plusmn', 86 => 'pound', 87 => 'quot', 88 => 'raquo', 89 => 'reg', 90 => 'sect', 91 => 'shy', 92 => 'sup1', 93 => 'sup2', 94 => 'sup3', 95 => 'szlig', 96 => 'thorn', 97 => 'times', 98 => 'uacute', 99 => 'ucirc', 100 => 'ugrave', 101 => 'uml', 102 => 'uuml', 103 => 'yacute', 104 => 'yen', 105 => 'yuml', )

The named references that decode without a semicolon (the HTML standard's legacy list).

privatestatic ?array $legacy

Public

statictext(string $raw): string#

Text with its character references decoded.

staticattribute(string $raw): string#

An attribute value with its character references decoded.

staticreference(string $context, string $text, int $at): ?array#

The character reference at $at in a context ("data" or "attribute"): its text and how many bytes it spans, or null when none decodes there.

@return array{0: string, 1: int}|null
staticchar(int $code): string#

The UTF-8 text for a code point, U+FFFD for one that cannot be a character, Windows-1252's for the C1 range.

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatedecode(string $raw, bool $inAttribute): string#
privatecodePoint(int $code): string#
privatelegacy(): array#
@return array<string, string> longest names first