1--TEST-- 2Translation of HTML entities for encoding MacRoman 3--FILE-- 4<?php 5$arr = array( 60x00C4 => array(0x80, "LATIN CAPITAL LETTER A WITH DIAERESIS"), 70x00C5 => array(0x81, "LATIN CAPITAL LETTER A WITH RING ABOVE"), 80x00C7 => array(0x82, "LATIN CAPITAL LETTER C WITH CEDILLA"), 90x00C9 => array(0x83, "LATIN CAPITAL LETTER E WITH ACUTE"), 100x00D1 => array(0x84, "LATIN CAPITAL LETTER N WITH TILDE"), 110x00D6 => array(0x85, "LATIN CAPITAL LETTER O WITH DIAERESIS"), 120x00DC => array(0x86, "LATIN CAPITAL LETTER U WITH DIAERESIS"), 130x00E1 => array(0x87, "LATIN SMALL LETTER A WITH ACUTE"), 140x00E0 => array(0x88, "LATIN SMALL LETTER A WITH GRAVE"), 150x00E2 => array(0x89, "LATIN SMALL LETTER A WITH CIRCUMFLEX"), 160x00E4 => array(0x8A, "LATIN SMALL LETTER A WITH DIAERESIS"), 170x00E3 => array(0x8B, "LATIN SMALL LETTER A WITH TILDE"), 180x00E5 => array(0x8C, "LATIN SMALL LETTER A WITH RING ABOVE"), 190x00E7 => array(0x8D, "LATIN SMALL LETTER C WITH CEDILLA"), 200x00E9 => array(0x8E, "LATIN SMALL LETTER E WITH ACUTE"), 210x00E8 => array(0x8F, "LATIN SMALL LETTER E WITH GRAVE"), 220x00EA => array(0x90, "LATIN SMALL LETTER E WITH CIRCUMFLEX"), 230x00EB => array(0x91, "LATIN SMALL LETTER E WITH DIAERESIS"), 240x00ED => array(0x92, "LATIN SMALL LETTER I WITH ACUTE"), 250x00EC => array(0x93, "LATIN SMALL LETTER I WITH GRAVE"), 260x00EE => array(0x94, "LATIN SMALL LETTER I WITH CIRCUMFLEX"), 270x00EF => array(0x95, "LATIN SMALL LETTER I WITH DIAERESIS"), 280x00F1 => array(0x96, "LATIN SMALL LETTER N WITH TILDE"), 290x00F3 => array(0x97, "LATIN SMALL LETTER O WITH ACUTE"), 300x00F2 => array(0x98, "LATIN SMALL LETTER O WITH GRAVE"), 310x00F4 => array(0x99, "LATIN SMALL LETTER O WITH CIRCUMFLEX"), 320x00F6 => array(0x9A, "LATIN SMALL LETTER O WITH DIAERESIS"), 330x00F5 => array(0x9B, "LATIN SMALL LETTER O WITH TILDE"), 340x00FA => array(0x9C, "LATIN SMALL LETTER U WITH ACUTE"), 350x00F9 => array(0x9D, "LATIN SMALL LETTER U WITH GRAVE"), 360x00FB => array(0x9E, "LATIN SMALL LETTER U WITH CIRCUMFLEX"), 370x00FC => array(0x9F, "LATIN SMALL LETTER U WITH DIAERESIS"), 380x2020 => array(0xA0, "DAGGER"), 390x00B0 => array(0xA1, "DEGREE SIGN"), 400x00A2 => array(0xA2, "CENT SIGN"), 410x00A3 => array(0xA3, "POUND SIGN"), 420x00A7 => array(0xA4, "SECTION SIGN"), 430x2022 => array(0xA5, "BULLET"), 440x00B6 => array(0xA6, "PILCROW SIGN"), 450x00DF => array(0xA7, "LATIN SMALL LETTER SHARP S"), 460x00AE => array(0xA8, "REGISTERED SIGN"), 470x00A9 => array(0xA9, "COPYRIGHT SIGN"), 480x2122 => array(0xAA, "TRADE MARK SIGN"), 490x00B4 => array(0xAB, "ACUTE ACCENT"), 500x00A8 => array(0xAC, "DIAERESIS"), 510x2260 => array(0xAD, "NOT EQUAL TO"), 520x00C6 => array(0xAE, "LATIN CAPITAL LETTER AE"), 530x00D8 => array(0xAF, "LATIN CAPITAL LETTER O WITH STROKE"), 540x221E => array(0xB0, "INFINITY"), 550x00B1 => array(0xB1, "PLUS-MINUS SIGN"), 560x2264 => array(0xB2, "LESS-THAN OR EQUAL TO"), 570x2265 => array(0xB3, "GREATER-THAN OR EQUAL TO"), 580x00A5 => array(0xB4, "YEN SIGN"), 590x00B5 => array(0xB5, "MICRO SIGN"), 600x2202 => array(0xB6, "PARTIAL DIFFERENTIAL"), 610x2211 => array(0xB7, "N-ARY SUMMATION"), 620x220F => array(0xB8, "N-ARY PRODUCT"), 630x03C0 => array(0xB9, "GREEK SMALL LETTER PI"), 640x222B => array(0xBA, "INTEGRAL"), 650x00AA => array(0xBB, "FEMININE ORDINAL INDICATOR"), 660x00BA => array(0xBC, "MASCULINE ORDINAL INDICATOR"), 670x03A9 => array(0xBD, "GREEK CAPITAL LETTER OMEGA"), 680x00E6 => array(0xBE, "LATIN SMALL LETTER AE"), 690x00F8 => array(0xBF, "LATIN SMALL LETTER O WITH STROKE"), 700x00BF => array(0xC0, "INVERTED QUESTION MARK"), 710x00A1 => array(0xC1, "INVERTED EXCLAMATION MARK"), 720x00AC => array(0xC2, "NOT SIGN"), 730x221A => array(0xC3, "SQUARE ROOT"), 740x0192 => array(0xC4, "LATIN SMALL LETTER F WITH HOOK"), 750x2248 => array(0xC5, "ALMOST EQUAL TO"), 760x2206 => array(0xC6, "INCREMENT"), 770x00AB => array(0xC7, "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK"), 780x00BB => array(0xC8, "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK"), 790x2026 => array(0xC9, "HORIZONTAL ELLIPSIS"), 800x00A0 => array(0xCA, "NO-BREAK SPACE"), 810x00C0 => array(0xCB, "LATIN CAPITAL LETTER A WITH GRAVE"), 820x00C3 => array(0xCC, "LATIN CAPITAL LETTER A WITH TILDE"), 830x00D5 => array(0xCD, "LATIN CAPITAL LETTER O WITH TILDE"), 840x0152 => array(0xCE, "LATIN CAPITAL LIGATURE OE"), 850x0153 => array(0xCF, "LATIN SMALL LIGATURE OE"), 860x2013 => array(0xD0, "EN DASH"), 870x2014 => array(0xD1, "EM DASH"), 880x201C => array(0xD2, "LEFT DOUBLE QUOTATION MARK"), 890x201D => array(0xD3, "RIGHT DOUBLE QUOTATION MARK"), 900x2018 => array(0xD4, "LEFT SINGLE QUOTATION MARK"), 910x2019 => array(0xD5, "RIGHT SINGLE QUOTATION MARK"), 920x00F7 => array(0xD6, "DIVISION SIGN"), 930x25CA => array(0xD7, "LOZENGE"), 940x00FF => array(0xD8, "LATIN SMALL LETTER Y WITH DIAERESIS"), 950x0178 => array(0xD9, "LATIN CAPITAL LETTER Y WITH DIAERESIS"), 960x2044 => array(0xDA, "FRACTION SLASH"), 970x20AC => array(0xDB, "EURO SIGN"), 980x2039 => array(0xDC, "SINGLE LEFT-POINTING ANGLE QUOTATION MARK"), 990x203A => array(0xDD, "SINGLE RIGHT-POINTING ANGLE QUOTATION MARK"), 1000xFB01 => array(0xDE, "LATIN SMALL LIGATURE FI"), 1010xFB02 => array(0xDF, "LATIN SMALL LIGATURE FL"), 1020x2021 => array(0xE0, "DOUBLE DAGGER"), 1030x00B7 => array(0xE1, "MIDDLE DOT"), 1040x201A => array(0xE2, "SINGLE LOW-9 QUOTATION MARK"), 1050x201E => array(0xE3, "DOUBLE LOW-9 QUOTATION MARK"), 1060x2030 => array(0xE4, "PER MILLE SIGN"), 1070x00C2 => array(0xE5, "LATIN CAPITAL LETTER A WITH CIRCUMFLEX"), 1080x00CA => array(0xE6, "LATIN CAPITAL LETTER E WITH CIRCUMFLEX"), 1090x00C1 => array(0xE7, "LATIN CAPITAL LETTER A WITH ACUTE"), 1100x00CB => array(0xE8, "LATIN CAPITAL LETTER E WITH DIAERESIS"), 1110x00C8 => array(0xE9, "LATIN CAPITAL LETTER E WITH GRAVE"), 1120x00CD => array(0xEA, "LATIN CAPITAL LETTER I WITH ACUTE"), 1130x00CE => array(0xEB, "LATIN CAPITAL LETTER I WITH CIRCUMFLEX"), 1140x00CF => array(0xEC, "LATIN CAPITAL LETTER I WITH DIAERESIS"), 1150x00CC => array(0xED, "LATIN CAPITAL LETTER I WITH GRAVE"), 1160x00D3 => array(0xEE, "LATIN CAPITAL LETTER O WITH ACUTE"), 1170x00D4 => array(0xEF, "LATIN CAPITAL LETTER O WITH CIRCUMFLEX"), 1180xF8FF => array(0xF0, "Apple logo"), 1190x00D2 => array(0xF1, "LATIN CAPITAL LETTER O WITH GRAVE"), 1200x00DA => array(0xF2, "LATIN CAPITAL LETTER U WITH ACUTE"), 1210x00DB => array(0xF3, "LATIN CAPITAL LETTER U WITH CIRCUMFLEX"), 1220x00D9 => array(0xF4, "LATIN CAPITAL LETTER U WITH GRAVE"), 1230x0131 => array(0xF5, "LATIN SMALL LETTER DOTLESS I"), 1240x02C6 => array(0xF6, "MODIFIER LETTER CIRCUMFLEX ACCENT"), 1250x02DC => array(0xF7, "SMALL TILDE"), 1260x00AF => array(0xF8, "MACRON"), 1270x02D8 => array(0xF9, "BREVE"), 1280x02D9 => array(0xFA, "DOT ABOVE"), 1290x02DA => array(0xFB, "RING ABOVE"), 1300x00B8 => array(0xFC, "CEDILLA"), 1310x02DD => array(0xFD, "DOUBLE ACUTE ACCENT"), 1320x02DB => array(0xFE, "OGONEK"), 1330x02C7 => array(0xFF, "CARON"), 134); 135 136$res = html_entity_decode("", ENT_QUOTES, 'MacRoman'); 137echo "Special test for  (shouldn't decode):\n"; 138echo $res,"\n\n"; 139 140foreach ($arr as $u => $v) { 141 $ent = sprintf("&#x%X;", $u); 142 $res = html_entity_decode($ent, ENT_QUOTES, 'MacRoman'); 143 $d = unpack("H*", $res); 144 echo sprintf("%s: %s => %s\n", $v[1], $ent, $d[1]); 145 146 $ent = sprintf("&#x%X;", $v[0]); 147 $res = html_entity_decode($ent, ENT_QUOTES, 'MacRoman'); 148 if ($res[0] != "&" || $res[1] != "#") 149 $res = unpack("H*", $res)[1]; 150 echo sprintf("%s => %s\n\n", $ent, $res); 151} 152--EXPECT-- 153Special test for  (shouldn't decode): 154 155 156LATIN CAPITAL LETTER A WITH DIAERESIS: Ä => 80 157€ => € 158 159LATIN CAPITAL LETTER A WITH RING ABOVE: Å => 81 160 =>  161 162LATIN CAPITAL LETTER C WITH CEDILLA: Ç => 82 163‚ => ‚ 164 165LATIN CAPITAL LETTER E WITH ACUTE: É => 83 166ƒ => ƒ 167 168LATIN CAPITAL LETTER N WITH TILDE: Ñ => 84 169„ => „ 170 171LATIN CAPITAL LETTER O WITH DIAERESIS: Ö => 85 172… => … 173 174LATIN CAPITAL LETTER U WITH DIAERESIS: Ü => 86 175† => † 176 177LATIN SMALL LETTER A WITH ACUTE: á => 87 178‡ => ‡ 179 180LATIN SMALL LETTER A WITH GRAVE: à => 88 181ˆ => ˆ 182 183LATIN SMALL LETTER A WITH CIRCUMFLEX: â => 89 184‰ => ‰ 185 186LATIN SMALL LETTER A WITH DIAERESIS: ä => 8a 187Š => Š 188 189LATIN SMALL LETTER A WITH TILDE: ã => 8b 190‹ => ‹ 191 192LATIN SMALL LETTER A WITH RING ABOVE: å => 8c 193Œ => Œ 194 195LATIN SMALL LETTER C WITH CEDILLA: ç => 8d 196 =>  197 198LATIN SMALL LETTER E WITH ACUTE: é => 8e 199Ž => Ž 200 201LATIN SMALL LETTER E WITH GRAVE: è => 8f 202 =>  203 204LATIN SMALL LETTER E WITH CIRCUMFLEX: ê => 90 205 =>  206 207LATIN SMALL LETTER E WITH DIAERESIS: ë => 91 208‘ => ‘ 209 210LATIN SMALL LETTER I WITH ACUTE: í => 92 211’ => ’ 212 213LATIN SMALL LETTER I WITH GRAVE: ì => 93 214“ => “ 215 216LATIN SMALL LETTER I WITH CIRCUMFLEX: î => 94 217” => ” 218 219LATIN SMALL LETTER I WITH DIAERESIS: ï => 95 220• => • 221 222LATIN SMALL LETTER N WITH TILDE: ñ => 96 223– => – 224 225LATIN SMALL LETTER O WITH ACUTE: ó => 97 226— => — 227 228LATIN SMALL LETTER O WITH GRAVE: ò => 98 229˜ => ˜ 230 231LATIN SMALL LETTER O WITH CIRCUMFLEX: ô => 99 232™ => ™ 233 234LATIN SMALL LETTER O WITH DIAERESIS: ö => 9a 235š => š 236 237LATIN SMALL LETTER O WITH TILDE: õ => 9b 238› => › 239 240LATIN SMALL LETTER U WITH ACUTE: ú => 9c 241œ => œ 242 243LATIN SMALL LETTER U WITH GRAVE: ù => 9d 244 =>  245 246LATIN SMALL LETTER U WITH CIRCUMFLEX: û => 9e 247ž => ž 248 249LATIN SMALL LETTER U WITH DIAERESIS: ü => 9f 250Ÿ => Ÿ 251 252DAGGER: † => a0 253  => ca 254 255DEGREE SIGN: ° => a1 256¡ => c1 257 258CENT SIGN: ¢ => a2 259¢ => a2 260 261POUND SIGN: £ => a3 262£ => a3 263 264SECTION SIGN: § => a4 265¤ => ¤ 266 267BULLET: • => a5 268¥ => b4 269 270PILCROW SIGN: ¶ => a6 271¦ => ¦ 272 273LATIN SMALL LETTER SHARP S: ß => a7 274§ => a4 275 276REGISTERED SIGN: ® => a8 277¨ => ac 278 279COPYRIGHT SIGN: © => a9 280© => a9 281 282TRADE MARK SIGN: ™ => aa 283ª => bb 284 285ACUTE ACCENT: ´ => ab 286« => c7 287 288DIAERESIS: ¨ => ac 289¬ => c2 290 291NOT EQUAL TO: ≠ => ad 292­ => ­ 293 294LATIN CAPITAL LETTER AE: Æ => ae 295® => a8 296 297LATIN CAPITAL LETTER O WITH STROKE: Ø => af 298¯ => f8 299 300INFINITY: ∞ => b0 301° => a1 302 303PLUS-MINUS SIGN: ± => b1 304± => b1 305 306LESS-THAN OR EQUAL TO: ≤ => b2 307² => ² 308 309GREATER-THAN OR EQUAL TO: ≥ => b3 310³ => ³ 311 312YEN SIGN: ¥ => b4 313´ => ab 314 315MICRO SIGN: µ => b5 316µ => b5 317 318PARTIAL DIFFERENTIAL: ∂ => b6 319¶ => a6 320 321N-ARY SUMMATION: ∑ => b7 322· => e1 323 324N-ARY PRODUCT: ∏ => b8 325¸ => fc 326 327GREEK SMALL LETTER PI: π => b9 328¹ => ¹ 329 330INTEGRAL: ∫ => ba 331º => bc 332 333FEMININE ORDINAL INDICATOR: ª => bb 334» => c8 335 336MASCULINE ORDINAL INDICATOR: º => bc 337¼ => ¼ 338 339GREEK CAPITAL LETTER OMEGA: Ω => bd 340½ => ½ 341 342LATIN SMALL LETTER AE: æ => be 343¾ => ¾ 344 345LATIN SMALL LETTER O WITH STROKE: ø => bf 346¿ => c0 347 348INVERTED QUESTION MARK: ¿ => c0 349À => cb 350 351INVERTED EXCLAMATION MARK: ¡ => c1 352Á => e7 353 354NOT SIGN: ¬ => c2 355 => e5 356 357SQUARE ROOT: √ => c3 358à => cc 359 360LATIN SMALL LETTER F WITH HOOK: ƒ => c4 361Ä => 80 362 363ALMOST EQUAL TO: ≈ => c5 364Å => 81 365 366INCREMENT: ∆ => c6 367Æ => ae 368 369LEFT-POINTING DOUBLE ANGLE QUOTATION MARK: « => c7 370Ç => 82 371 372RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK: » => c8 373È => e9 374 375HORIZONTAL ELLIPSIS: … => c9 376É => 83 377 378NO-BREAK SPACE:   => ca 379Ê => e6 380 381LATIN CAPITAL LETTER A WITH GRAVE: À => cb 382Ë => e8 383 384LATIN CAPITAL LETTER A WITH TILDE: à => cc 385Ì => ed 386 387LATIN CAPITAL LETTER O WITH TILDE: Õ => cd 388Í => ea 389 390LATIN CAPITAL LIGATURE OE: Œ => ce 391Î => eb 392 393LATIN SMALL LIGATURE OE: œ => cf 394Ï => ec 395 396EN DASH: – => d0 397Ð => Ð 398 399EM DASH: — => d1 400Ñ => 84 401 402LEFT DOUBLE QUOTATION MARK: “ => d2 403Ò => f1 404 405RIGHT DOUBLE QUOTATION MARK: ” => d3 406Ó => ee 407 408LEFT SINGLE QUOTATION MARK: ‘ => d4 409Ô => ef 410 411RIGHT SINGLE QUOTATION MARK: ’ => d5 412Õ => cd 413 414DIVISION SIGN: ÷ => d6 415Ö => 85 416 417LOZENGE: ◊ => d7 418× => × 419 420LATIN SMALL LETTER Y WITH DIAERESIS: ÿ => d8 421Ø => af 422 423LATIN CAPITAL LETTER Y WITH DIAERESIS: Ÿ => d9 424Ù => f4 425 426FRACTION SLASH: ⁄ => da 427Ú => f2 428 429EURO SIGN: € => db 430Û => f3 431 432SINGLE LEFT-POINTING ANGLE QUOTATION MARK: ‹ => dc 433Ü => 86 434 435SINGLE RIGHT-POINTING ANGLE QUOTATION MARK: › => dd 436Ý => Ý 437 438LATIN SMALL LIGATURE FI: fi => de 439Þ => Þ 440 441LATIN SMALL LIGATURE FL: fl => df 442ß => a7 443 444DOUBLE DAGGER: ‡ => e0 445à => 88 446 447MIDDLE DOT: · => e1 448á => 87 449 450SINGLE LOW-9 QUOTATION MARK: ‚ => e2 451â => 89 452 453DOUBLE LOW-9 QUOTATION MARK: „ => e3 454ã => 8b 455 456PER MILLE SIGN: ‰ => e4 457ä => 8a 458 459LATIN CAPITAL LETTER A WITH CIRCUMFLEX:  => e5 460å => 8c 461 462LATIN CAPITAL LETTER E WITH CIRCUMFLEX: Ê => e6 463æ => be 464 465LATIN CAPITAL LETTER A WITH ACUTE: Á => e7 466ç => 8d 467 468LATIN CAPITAL LETTER E WITH DIAERESIS: Ë => e8 469è => 8f 470 471LATIN CAPITAL LETTER E WITH GRAVE: È => e9 472é => 8e 473 474LATIN CAPITAL LETTER I WITH ACUTE: Í => ea 475ê => 90 476 477LATIN CAPITAL LETTER I WITH CIRCUMFLEX: Î => eb 478ë => 91 479 480LATIN CAPITAL LETTER I WITH DIAERESIS: Ï => ec 481ì => 93 482 483LATIN CAPITAL LETTER I WITH GRAVE: Ì => ed 484í => 92 485 486LATIN CAPITAL LETTER O WITH ACUTE: Ó => ee 487î => 94 488 489LATIN CAPITAL LETTER O WITH CIRCUMFLEX: Ô => ef 490ï => 95 491 492Apple logo:  => f0 493ð => ð 494 495LATIN CAPITAL LETTER O WITH GRAVE: Ò => f1 496ñ => 96 497 498LATIN CAPITAL LETTER U WITH ACUTE: Ú => f2 499ò => 98 500 501LATIN CAPITAL LETTER U WITH CIRCUMFLEX: Û => f3 502ó => 97 503 504LATIN CAPITAL LETTER U WITH GRAVE: Ù => f4 505ô => 99 506 507LATIN SMALL LETTER DOTLESS I: ı => f5 508õ => 9b 509 510MODIFIER LETTER CIRCUMFLEX ACCENT: ˆ => f6 511ö => 9a 512 513SMALL TILDE: ˜ => f7 514÷ => d6 515 516MACRON: ¯ => f8 517ø => bf 518 519BREVE: ˘ => f9 520ù => 9d 521 522DOT ABOVE: ˙ => fa 523ú => 9c 524 525RING ABOVE: ˚ => fb 526û => 9e 527 528CEDILLA: ¸ => fc 529ü => 9f 530 531DOUBLE ACUTE ACCENT: ˝ => fd 532ý => ý 533 534OGONEK: ˛ => fe 535þ => þ 536 537CARON: ˇ => ff 538ÿ => d8 539