1--TEST-- 2htmlentities() conformance check (HTML 4) 3--FILE-- 4<?php 5function utf32_utf8($k) { 6 if ($k < 0x80) { 7 $retval = pack('C', $k); 8 } else if ($k < 0x800) { 9 $retval = pack('C2', 10 0xc0 | ($k >> 6), 11 0x80 | ($k & 0x3f)); 12 } else if ($k < 0x10000) { 13 $retval = pack('C3', 14 0xe0 | ($k >> 12), 15 0x80 | (($k >> 6) & 0x3f), 16 0x80 | ($k & 0x3f)); 17 } else if ($k < 0x200000) { 18 $retval = pack('C4', 19 0xf0 | ($k >> 18), 20 0x80 | (($k >> 12) & 0x3f), 21 0x80 | (($k >> 6) & 0x3f), 22 0x80 | ($k & 0x3f)); 23 } else if ($k < 0x4000000) { 24 $retval = pack('C5', 25 0xf8 | ($k >> 24), 26 0x80 | (($k >> 18) & 0x3f), 27 0x80 | (($k >> 12) & 0x3f), 28 0x80 | (($k >> 6) & 0x3f), 29 0x80 | ($k & 0x3f)); 30 } else { 31 $retval = pack('C6', 32 0xfc | ($k >> 30), 33 0x80 | (($k >> 24) & 0x3f), 34 0x80 | (($k >> 18) & 0x3f), 35 0x80 | (($k >> 12) & 0x3f), 36 0x80 | (($k >> 6) & 0x3f), 37 0x80 | ($k & 0x3f)); 38 } 39 return $retval; 40} 41 42$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, 'UTF-8'); 43 44for ($i = 0; $i < 0x2710; $i++) { 45 if ($i >= 0xd800 && $i < 0xe000) 46 continue; 47 $str = utf32_utf8($i); 48 if (isset($table[$str])) { 49 printf("%s\tU+%05X\n", $table[$str], $i); 50 unset($table[$str]); 51 } 52} 53 54if (!empty($table)) { 55 echo "Not matched entities: "; 56 var_dump($table); 57} 58 59?> 60--EXPECT-- 61" U+00022 62& U+00026 63' U+00027 64< U+0003C 65> U+0003E 66 U+000A0 67¡ U+000A1 68¢ U+000A2 69£ U+000A3 70¤ U+000A4 71¥ U+000A5 72¦ U+000A6 73§ U+000A7 74¨ U+000A8 75© U+000A9 76ª U+000AA 77« U+000AB 78¬ U+000AC 79­ U+000AD 80® U+000AE 81¯ U+000AF 82° U+000B0 83± U+000B1 84² U+000B2 85³ U+000B3 86´ U+000B4 87µ U+000B5 88¶ U+000B6 89· U+000B7 90¸ U+000B8 91¹ U+000B9 92º U+000BA 93» U+000BB 94¼ U+000BC 95½ U+000BD 96¾ U+000BE 97¿ U+000BF 98À U+000C0 99Á U+000C1 100 U+000C2 101à U+000C3 102Ä U+000C4 103Å U+000C5 104Æ U+000C6 105Ç U+000C7 106È U+000C8 107É U+000C9 108Ê U+000CA 109Ë U+000CB 110Ì U+000CC 111Í U+000CD 112Î U+000CE 113Ï U+000CF 114Ð U+000D0 115Ñ U+000D1 116Ò U+000D2 117Ó U+000D3 118Ô U+000D4 119Õ U+000D5 120Ö U+000D6 121× U+000D7 122Ø U+000D8 123Ù U+000D9 124Ú U+000DA 125Û U+000DB 126Ü U+000DC 127Ý U+000DD 128Þ U+000DE 129ß U+000DF 130à U+000E0 131á U+000E1 132â U+000E2 133ã U+000E3 134ä U+000E4 135å U+000E5 136æ U+000E6 137ç U+000E7 138è U+000E8 139é U+000E9 140ê U+000EA 141ë U+000EB 142ì U+000EC 143í U+000ED 144î U+000EE 145ï U+000EF 146ð U+000F0 147ñ U+000F1 148ò U+000F2 149ó U+000F3 150ô U+000F4 151õ U+000F5 152ö U+000F6 153÷ U+000F7 154ø U+000F8 155ù U+000F9 156ú U+000FA 157û U+000FB 158ü U+000FC 159ý U+000FD 160þ U+000FE 161ÿ U+000FF 162Œ U+00152 163œ U+00153 164Š U+00160 165š U+00161 166Ÿ U+00178 167ƒ U+00192 168ˆ U+002C6 169˜ U+002DC 170Α U+00391 171Β U+00392 172Γ U+00393 173Δ U+00394 174Ε U+00395 175Ζ U+00396 176Η U+00397 177Θ U+00398 178Ι U+00399 179Κ U+0039A 180Λ U+0039B 181Μ U+0039C 182Ν U+0039D 183Ξ U+0039E 184Ο U+0039F 185Π U+003A0 186Ρ U+003A1 187Σ U+003A3 188Τ U+003A4 189Υ U+003A5 190Φ U+003A6 191Χ U+003A7 192Ψ U+003A8 193Ω U+003A9 194α U+003B1 195β U+003B2 196γ U+003B3 197δ U+003B4 198ε U+003B5 199ζ U+003B6 200η U+003B7 201θ U+003B8 202ι U+003B9 203κ U+003BA 204λ U+003BB 205μ U+003BC 206ν U+003BD 207ξ U+003BE 208ο U+003BF 209π U+003C0 210ρ U+003C1 211ς U+003C2 212σ U+003C3 213τ U+003C4 214υ U+003C5 215φ U+003C6 216χ U+003C7 217ψ U+003C8 218ω U+003C9 219ϑ U+003D1 220ϒ U+003D2 221ϖ U+003D6 222  U+02002 223  U+02003 224  U+02009 225‌ U+0200C 226‍ U+0200D 227‎ U+0200E 228‏ U+0200F 229– U+02013 230— U+02014 231‘ U+02018 232’ U+02019 233‚ U+0201A 234“ U+0201C 235” U+0201D 236„ U+0201E 237† U+02020 238‡ U+02021 239• U+02022 240… U+02026 241‰ U+02030 242′ U+02032 243″ U+02033 244‹ U+02039 245› U+0203A 246‾ U+0203E 247⁄ U+02044 248€ U+020AC 249ℑ U+02111 250℘ U+02118 251ℜ U+0211C 252™ U+02122 253ℵ U+02135 254← U+02190 255↑ U+02191 256→ U+02192 257↓ U+02193 258↔ U+02194 259↵ U+021B5 260⇐ U+021D0 261⇑ U+021D1 262⇒ U+021D2 263⇓ U+021D3 264⇔ U+021D4 265∀ U+02200 266∂ U+02202 267∃ U+02203 268∅ U+02205 269∇ U+02207 270∈ U+02208 271∉ U+02209 272∋ U+0220B 273∏ U+0220F 274∑ U+02211 275− U+02212 276∗ U+02217 277√ U+0221A 278∝ U+0221D 279∞ U+0221E 280∠ U+02220 281∧ U+02227 282∨ U+02228 283∩ U+02229 284∪ U+0222A 285∫ U+0222B 286∴ U+02234 287∼ U+0223C 288≅ U+02245 289≈ U+02248 290≠ U+02260 291≡ U+02261 292≤ U+02264 293≥ U+02265 294⊂ U+02282 295⊃ U+02283 296⊄ U+02284 297⊆ U+02286 298⊇ U+02287 299⊕ U+02295 300⊗ U+02297 301⊥ U+022A5 302⋅ U+022C5 303⌈ U+02308 304⌉ U+02309 305⌊ U+0230A 306⌋ U+0230B 307⟨ U+02329 308⟩ U+0232A 309◊ U+025CA 310♠ U+02660 311♣ U+02663 312♥ U+02665 313♦ U+02666 314