1--TEST-- 2Translation of HTML entities for encoding CP866 3--FILE-- 4<?php 5$arr = array( 60x0410 => array(0x80, "CYRILLIC CAPITAL LETTER A"), 70x0411 => array(0x81, "CYRILLIC CAPITAL LETTER BE"), 80x0412 => array(0x82, "CYRILLIC CAPITAL LETTER VE"), 90x0413 => array(0x83, "CYRILLIC CAPITAL LETTER GHE"), 100x0414 => array(0x84, "CYRILLIC CAPITAL LETTER DE"), 110x0415 => array(0x85, "CYRILLIC CAPITAL LETTER IE"), 120x0416 => array(0x86, "CYRILLIC CAPITAL LETTER ZHE"), 130x0417 => array(0x87, "CYRILLIC CAPITAL LETTER ZE"), 140x0418 => array(0x88, "CYRILLIC CAPITAL LETTER I"), 150x0419 => array(0x89, "CYRILLIC CAPITAL LETTER SHORT I"), 160x041a => array(0x8a, "CYRILLIC CAPITAL LETTER KA"), 170x041b => array(0x8b, "CYRILLIC CAPITAL LETTER EL"), 180x041c => array(0x8c, "CYRILLIC CAPITAL LETTER EM"), 190x041d => array(0x8d, "CYRILLIC CAPITAL LETTER EN"), 200x041e => array(0x8e, "CYRILLIC CAPITAL LETTER O"), 210x041f => array(0x8f, "CYRILLIC CAPITAL LETTER PE"), 220x0420 => array(0x90, "CYRILLIC CAPITAL LETTER ER"), 230x0421 => array(0x91, "CYRILLIC CAPITAL LETTER ES"), 240x0422 => array(0x92, "CYRILLIC CAPITAL LETTER TE"), 250x0423 => array(0x93, "CYRILLIC CAPITAL LETTER U"), 260x0424 => array(0x94, "CYRILLIC CAPITAL LETTER EF"), 270x0425 => array(0x95, "CYRILLIC CAPITAL LETTER HA"), 280x0426 => array(0x96, "CYRILLIC CAPITAL LETTER TSE"), 290x0427 => array(0x97, "CYRILLIC CAPITAL LETTER CHE"), 300x0428 => array(0x98, "CYRILLIC CAPITAL LETTER SHA"), 310x0429 => array(0x99, "CYRILLIC CAPITAL LETTER SHCHA"), 320x042a => array(0x9a, "CYRILLIC CAPITAL LETTER HARD SIGN"), 330x042b => array(0x9b, "CYRILLIC CAPITAL LETTER YERU"), 340x042c => array(0x9c, "CYRILLIC CAPITAL LETTER SOFT SIGN"), 350x042d => array(0x9d, "CYRILLIC CAPITAL LETTER E"), 360x042e => array(0x9e, "CYRILLIC CAPITAL LETTER YU"), 370x042f => array(0x9f, "CYRILLIC CAPITAL LETTER YA"), 380x0430 => array(0xa0, "CYRILLIC SMALL LETTER A"), 390x0431 => array(0xa1, "CYRILLIC SMALL LETTER BE"), 400x0432 => array(0xa2, "CYRILLIC SMALL LETTER VE"), 410x0433 => array(0xa3, "CYRILLIC SMALL LETTER GHE"), 420x0434 => array(0xa4, "CYRILLIC SMALL LETTER DE"), 430x0435 => array(0xa5, "CYRILLIC SMALL LETTER IE"), 440x0436 => array(0xa6, "CYRILLIC SMALL LETTER ZHE"), 450x0437 => array(0xa7, "CYRILLIC SMALL LETTER ZE"), 460x0438 => array(0xa8, "CYRILLIC SMALL LETTER I"), 470x0439 => array(0xa9, "CYRILLIC SMALL LETTER SHORT I"), 480x043a => array(0xaa, "CYRILLIC SMALL LETTER KA"), 490x043b => array(0xab, "CYRILLIC SMALL LETTER EL"), 500x043c => array(0xac, "CYRILLIC SMALL LETTER EM"), 510x043d => array(0xad, "CYRILLIC SMALL LETTER EN"), 520x043e => array(0xae, "CYRILLIC SMALL LETTER O"), 530x043f => array(0xaf, "CYRILLIC SMALL LETTER PE"), 540x2591 => array(0xb0, "LIGHT SHADE"), 550x2592 => array(0xb1, "MEDIUM SHADE"), 560x2593 => array(0xb2, "DARK SHADE"), 570x2502 => array(0xb3, "BOX DRAWINGS LIGHT VERTICAL"), 580x2524 => array(0xb4, "BOX DRAWINGS LIGHT VERTICAL AND LEFT"), 590x2561 => array(0xb5, "BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE"), 600x2562 => array(0xb6, "BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE"), 610x2556 => array(0xb7, "BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE"), 620x2555 => array(0xb8, "BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE"), 630x2563 => array(0xb9, "BOX DRAWINGS DOUBLE VERTICAL AND LEFT"), 640x2551 => array(0xba, "BOX DRAWINGS DOUBLE VERTICAL"), 650x2557 => array(0xbb, "BOX DRAWINGS DOUBLE DOWN AND LEFT"), 660x255d => array(0xbc, "BOX DRAWINGS DOUBLE UP AND LEFT"), 670x255c => array(0xbd, "BOX DRAWINGS UP DOUBLE AND LEFT SINGLE"), 680x255b => array(0xbe, "BOX DRAWINGS UP SINGLE AND LEFT DOUBLE"), 690x2510 => array(0xbf, "BOX DRAWINGS LIGHT DOWN AND LEFT"), 700x2514 => array(0xc0, "BOX DRAWINGS LIGHT UP AND RIGHT"), 710x2534 => array(0xc1, "BOX DRAWINGS LIGHT UP AND HORIZONTAL"), 720x252c => array(0xc2, "BOX DRAWINGS LIGHT DOWN AND HORIZONTAL"), 730x251c => array(0xc3, "BOX DRAWINGS LIGHT VERTICAL AND RIGHT"), 740x2500 => array(0xc4, "BOX DRAWINGS LIGHT HORIZONTAL"), 750x253c => array(0xc5, "BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL"), 760x255e => array(0xc6, "BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE"), 770x255f => array(0xc7, "BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE"), 780x255a => array(0xc8, "BOX DRAWINGS DOUBLE UP AND RIGHT"), 790x2554 => array(0xc9, "BOX DRAWINGS DOUBLE DOWN AND RIGHT"), 800x2569 => array(0xca, "BOX DRAWINGS DOUBLE UP AND HORIZONTAL"), 810x2566 => array(0xcb, "BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL"), 820x2560 => array(0xcc, "BOX DRAWINGS DOUBLE VERTICAL AND RIGHT"), 830x2550 => array(0xcd, "BOX DRAWINGS DOUBLE HORIZONTAL"), 840x256c => array(0xce, "BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL"), 850x2567 => array(0xcf, "BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE"), 860x2568 => array(0xd0, "BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE"), 870x2564 => array(0xd1, "BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE"), 880x2565 => array(0xd2, "BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE"), 890x2559 => array(0xd3, "BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE"), 900x2558 => array(0xd4, "BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE"), 910x2552 => array(0xd5, "BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE"), 920x2553 => array(0xd6, "BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE"), 930x256b => array(0xd7, "BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE"), 940x256a => array(0xd8, "BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE"), 950x2518 => array(0xd9, "BOX DRAWINGS LIGHT UP AND LEFT"), 960x250c => array(0xda, "BOX DRAWINGS LIGHT DOWN AND RIGHT"), 970x2588 => array(0xdb, "FULL BLOCK"), 980x2584 => array(0xdc, "LOWER HALF BLOCK"), 990x258c => array(0xdd, "LEFT HALF BLOCK"), 1000x2590 => array(0xde, "RIGHT HALF BLOCK"), 1010x2580 => array(0xdf, "UPPER HALF BLOCK"), 1020x0440 => array(0xe0, "CYRILLIC SMALL LETTER ER"), 1030x0441 => array(0xe1, "CYRILLIC SMALL LETTER ES"), 1040x0442 => array(0xe2, "CYRILLIC SMALL LETTER TE"), 1050x0443 => array(0xe3, "CYRILLIC SMALL LETTER U"), 1060x0444 => array(0xe4, "CYRILLIC SMALL LETTER EF"), 1070x0445 => array(0xe5, "CYRILLIC SMALL LETTER HA"), 1080x0446 => array(0xe6, "CYRILLIC SMALL LETTER TSE"), 1090x0447 => array(0xe7, "CYRILLIC SMALL LETTER CHE"), 1100x0448 => array(0xe8, "CYRILLIC SMALL LETTER SHA"), 1110x0449 => array(0xe9, "CYRILLIC SMALL LETTER SHCHA"), 1120x044a => array(0xea, "CYRILLIC SMALL LETTER HARD SIGN"), 1130x044b => array(0xeb, "CYRILLIC SMALL LETTER YERU"), 1140x044c => array(0xec, "CYRILLIC SMALL LETTER SOFT SIGN"), 1150x044d => array(0xed, "CYRILLIC SMALL LETTER E"), 1160x044e => array(0xee, "CYRILLIC SMALL LETTER YU"), 1170x044f => array(0xef, "CYRILLIC SMALL LETTER YA"), 1180x0401 => array(0xf0, "CYRILLIC CAPITAL LETTER IO"), 1190x0451 => array(0xf1, "CYRILLIC SMALL LETTER IO"), 1200x0404 => array(0xf2, "CYRILLIC CAPITAL LETTER UKRAINIAN IE"), 1210x0454 => array(0xf3, "CYRILLIC SMALL LETTER UKRAINIAN IE"), 1220x0407 => array(0xf4, "CYRILLIC CAPITAL LETTER YI"), 1230x0457 => array(0xf5, "CYRILLIC SMALL LETTER YI"), 1240x040e => array(0xf6, "CYRILLIC CAPITAL LETTER SHORT U"), 1250x045e => array(0xf7, "CYRILLIC SMALL LETTER SHORT U"), 1260x00b0 => array(0xf8, "DEGREE SIGN"), 1270x2219 => array(0xf9, "BULLET OPERATOR"), 1280x00b7 => array(0xfa, "MIDDLE DOT"), 1290x221a => array(0xfb, "SQUARE ROOT"), 1300x2116 => array(0xfc, "NUMERO SIGN"), 1310x00a4 => array(0xfd, "CURRENCY SIGN"), 1320x25a0 => array(0xfe, "BLACK SQUARE"), 1330x00a0 => array(0xff, "NO-BREAK SPACE"), 134); 135 136foreach ($arr as $u => $v) { 137 $ent = sprintf("&#x%X;", $u); 138 $res = html_entity_decode($ent, ENT_QUOTES, 'CP866'); 139 $d = unpack("H*", $res); 140 echo sprintf("%s: %s => %s\n", $v[1], $ent, $d[1]); 141 142 $ent = sprintf("&#x%X;", $v[0]); 143 $res = html_entity_decode($ent, ENT_QUOTES, 'CP866'); 144 if ($res[0] != "&" || $res[1] != "#") 145 $res = unpack("H*", $res)[1]; 146 echo sprintf("%s => %s\n\n", $ent, $res); 147} 148?> 149--EXPECT-- 150CYRILLIC CAPITAL LETTER A: А => 80 151€ => € 152 153CYRILLIC CAPITAL LETTER BE: Б => 81 154 =>  155 156CYRILLIC CAPITAL LETTER VE: В => 82 157‚ => ‚ 158 159CYRILLIC CAPITAL LETTER GHE: Г => 83 160ƒ => ƒ 161 162CYRILLIC CAPITAL LETTER DE: Д => 84 163„ => „ 164 165CYRILLIC CAPITAL LETTER IE: Е => 85 166… => … 167 168CYRILLIC CAPITAL LETTER ZHE: Ж => 86 169† => † 170 171CYRILLIC CAPITAL LETTER ZE: З => 87 172‡ => ‡ 173 174CYRILLIC CAPITAL LETTER I: И => 88 175ˆ => ˆ 176 177CYRILLIC CAPITAL LETTER SHORT I: Й => 89 178‰ => ‰ 179 180CYRILLIC CAPITAL LETTER KA: К => 8a 181Š => Š 182 183CYRILLIC CAPITAL LETTER EL: Л => 8b 184‹ => ‹ 185 186CYRILLIC CAPITAL LETTER EM: М => 8c 187Œ => Œ 188 189CYRILLIC CAPITAL LETTER EN: Н => 8d 190 =>  191 192CYRILLIC CAPITAL LETTER O: О => 8e 193Ž => Ž 194 195CYRILLIC CAPITAL LETTER PE: П => 8f 196 =>  197 198CYRILLIC CAPITAL LETTER ER: Р => 90 199 =>  200 201CYRILLIC CAPITAL LETTER ES: С => 91 202‘ => ‘ 203 204CYRILLIC CAPITAL LETTER TE: Т => 92 205’ => ’ 206 207CYRILLIC CAPITAL LETTER U: У => 93 208“ => “ 209 210CYRILLIC CAPITAL LETTER EF: Ф => 94 211” => ” 212 213CYRILLIC CAPITAL LETTER HA: Х => 95 214• => • 215 216CYRILLIC CAPITAL LETTER TSE: Ц => 96 217– => – 218 219CYRILLIC CAPITAL LETTER CHE: Ч => 97 220— => — 221 222CYRILLIC CAPITAL LETTER SHA: Ш => 98 223˜ => ˜ 224 225CYRILLIC CAPITAL LETTER SHCHA: Щ => 99 226™ => ™ 227 228CYRILLIC CAPITAL LETTER HARD SIGN: Ъ => 9a 229š => š 230 231CYRILLIC CAPITAL LETTER YERU: Ы => 9b 232› => › 233 234CYRILLIC CAPITAL LETTER SOFT SIGN: Ь => 9c 235œ => œ 236 237CYRILLIC CAPITAL LETTER E: Э => 9d 238 =>  239 240CYRILLIC CAPITAL LETTER YU: Ю => 9e 241ž => ž 242 243CYRILLIC CAPITAL LETTER YA: Я => 9f 244Ÿ => Ÿ 245 246CYRILLIC SMALL LETTER A: а => a0 247  => ff 248 249CYRILLIC SMALL LETTER BE: б => a1 250¡ => ¡ 251 252CYRILLIC SMALL LETTER VE: в => a2 253¢ => ¢ 254 255CYRILLIC SMALL LETTER GHE: г => a3 256£ => £ 257 258CYRILLIC SMALL LETTER DE: д => a4 259¤ => fd 260 261CYRILLIC SMALL LETTER IE: е => a5 262¥ => ¥ 263 264CYRILLIC SMALL LETTER ZHE: ж => a6 265¦ => ¦ 266 267CYRILLIC SMALL LETTER ZE: з => a7 268§ => § 269 270CYRILLIC SMALL LETTER I: и => a8 271¨ => ¨ 272 273CYRILLIC SMALL LETTER SHORT I: й => a9 274© => © 275 276CYRILLIC SMALL LETTER KA: к => aa 277ª => ª 278 279CYRILLIC SMALL LETTER EL: л => ab 280« => « 281 282CYRILLIC SMALL LETTER EM: м => ac 283¬ => ¬ 284 285CYRILLIC SMALL LETTER EN: н => ad 286­ => ­ 287 288CYRILLIC SMALL LETTER O: о => ae 289® => ® 290 291CYRILLIC SMALL LETTER PE: п => af 292¯ => ¯ 293 294LIGHT SHADE: ░ => b0 295° => f8 296 297MEDIUM SHADE: ▒ => b1 298± => ± 299 300DARK SHADE: ▓ => b2 301² => ² 302 303BOX DRAWINGS LIGHT VERTICAL: │ => b3 304³ => ³ 305 306BOX DRAWINGS LIGHT VERTICAL AND LEFT: ┤ => b4 307´ => ´ 308 309BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE: ╡ => b5 310µ => µ 311 312BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE: ╢ => b6 313¶ => ¶ 314 315BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE: ╖ => b7 316· => fa 317 318BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE: ╕ => b8 319¸ => ¸ 320 321BOX DRAWINGS DOUBLE VERTICAL AND LEFT: ╣ => b9 322¹ => ¹ 323 324BOX DRAWINGS DOUBLE VERTICAL: ║ => ba 325º => º 326 327BOX DRAWINGS DOUBLE DOWN AND LEFT: ╗ => bb 328» => » 329 330BOX DRAWINGS DOUBLE UP AND LEFT: ╝ => bc 331¼ => ¼ 332 333BOX DRAWINGS UP DOUBLE AND LEFT SINGLE: ╜ => bd 334½ => ½ 335 336BOX DRAWINGS UP SINGLE AND LEFT DOUBLE: ╛ => be 337¾ => ¾ 338 339BOX DRAWINGS LIGHT DOWN AND LEFT: ┐ => bf 340¿ => ¿ 341 342BOX DRAWINGS LIGHT UP AND RIGHT: └ => c0 343À => À 344 345BOX DRAWINGS LIGHT UP AND HORIZONTAL: ┴ => c1 346Á => Á 347 348BOX DRAWINGS LIGHT DOWN AND HORIZONTAL: ┬ => c2 349 =>  350 351BOX DRAWINGS LIGHT VERTICAL AND RIGHT: ├ => c3 352à => à 353 354BOX DRAWINGS LIGHT HORIZONTAL: ─ => c4 355Ä => Ä 356 357BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL: ┼ => c5 358Å => Å 359 360BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE: ╞ => c6 361Æ => Æ 362 363BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE: ╟ => c7 364Ç => Ç 365 366BOX DRAWINGS DOUBLE UP AND RIGHT: ╚ => c8 367È => È 368 369BOX DRAWINGS DOUBLE DOWN AND RIGHT: ╔ => c9 370É => É 371 372BOX DRAWINGS DOUBLE UP AND HORIZONTAL: ╩ => ca 373Ê => Ê 374 375BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL: ╦ => cb 376Ë => Ë 377 378BOX DRAWINGS DOUBLE VERTICAL AND RIGHT: ╠ => cc 379Ì => Ì 380 381BOX DRAWINGS DOUBLE HORIZONTAL: ═ => cd 382Í => Í 383 384BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: ╬ => ce 385Î => Î 386 387BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE: ╧ => cf 388Ï => Ï 389 390BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE: ╨ => d0 391Ð => Ð 392 393BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE: ╤ => d1 394Ñ => Ñ 395 396BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE: ╥ => d2 397Ò => Ò 398 399BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE: ╙ => d3 400Ó => Ó 401 402BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE: ╘ => d4 403Ô => Ô 404 405BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE: ╒ => d5 406Õ => Õ 407 408BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE: ╓ => d6 409Ö => Ö 410 411BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE: ╫ => d7 412× => × 413 414BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE: ╪ => d8 415Ø => Ø 416 417BOX DRAWINGS LIGHT UP AND LEFT: ┘ => d9 418Ù => Ù 419 420BOX DRAWINGS LIGHT DOWN AND RIGHT: ┌ => da 421Ú => Ú 422 423FULL BLOCK: █ => db 424Û => Û 425 426LOWER HALF BLOCK: ▄ => dc 427Ü => Ü 428 429LEFT HALF BLOCK: ▌ => dd 430Ý => Ý 431 432RIGHT HALF BLOCK: ▐ => de 433Þ => Þ 434 435UPPER HALF BLOCK: ▀ => df 436ß => ß 437 438CYRILLIC SMALL LETTER ER: р => e0 439à => à 440 441CYRILLIC SMALL LETTER ES: с => e1 442á => á 443 444CYRILLIC SMALL LETTER TE: т => e2 445â => â 446 447CYRILLIC SMALL LETTER U: у => e3 448ã => ã 449 450CYRILLIC SMALL LETTER EF: ф => e4 451ä => ä 452 453CYRILLIC SMALL LETTER HA: х => e5 454å => å 455 456CYRILLIC SMALL LETTER TSE: ц => e6 457æ => æ 458 459CYRILLIC SMALL LETTER CHE: ч => e7 460ç => ç 461 462CYRILLIC SMALL LETTER SHA: ш => e8 463è => è 464 465CYRILLIC SMALL LETTER SHCHA: щ => e9 466é => é 467 468CYRILLIC SMALL LETTER HARD SIGN: ъ => ea 469ê => ê 470 471CYRILLIC SMALL LETTER YERU: ы => eb 472ë => ë 473 474CYRILLIC SMALL LETTER SOFT SIGN: ь => ec 475ì => ì 476 477CYRILLIC SMALL LETTER E: э => ed 478í => í 479 480CYRILLIC SMALL LETTER YU: ю => ee 481î => î 482 483CYRILLIC SMALL LETTER YA: я => ef 484ï => ï 485 486CYRILLIC CAPITAL LETTER IO: Ё => f0 487ð => ð 488 489CYRILLIC SMALL LETTER IO: ё => f1 490ñ => ñ 491 492CYRILLIC CAPITAL LETTER UKRAINIAN IE: Є => f2 493ò => ò 494 495CYRILLIC SMALL LETTER UKRAINIAN IE: є => f3 496ó => ó 497 498CYRILLIC CAPITAL LETTER YI: Ї => f4 499ô => ô 500 501CYRILLIC SMALL LETTER YI: ї => f5 502õ => õ 503 504CYRILLIC CAPITAL LETTER SHORT U: Ў => f6 505ö => ö 506 507CYRILLIC SMALL LETTER SHORT U: ў => f7 508÷ => ÷ 509 510DEGREE SIGN: ° => f8 511ø => ø 512 513BULLET OPERATOR: ∙ => f9 514ù => ù 515 516MIDDLE DOT: · => fa 517ú => ú 518 519SQUARE ROOT: √ => fb 520û => û 521 522NUMERO SIGN: № => fc 523ü => ü 524 525CURRENCY SIGN: ¤ => fd 526ý => ý 527 528BLACK SQUARE: ■ => fe 529þ => þ 530 531NO-BREAK SPACE:   => ff 532ÿ => ÿ 533