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--EXPECT-- 149CYRILLIC CAPITAL LETTER A: А => 80 150€ => € 151 152CYRILLIC CAPITAL LETTER BE: Б => 81 153 =>  154 155CYRILLIC CAPITAL LETTER VE: В => 82 156‚ => ‚ 157 158CYRILLIC CAPITAL LETTER GHE: Г => 83 159ƒ => ƒ 160 161CYRILLIC CAPITAL LETTER DE: Д => 84 162„ => „ 163 164CYRILLIC CAPITAL LETTER IE: Е => 85 165… => … 166 167CYRILLIC CAPITAL LETTER ZHE: Ж => 86 168† => † 169 170CYRILLIC CAPITAL LETTER ZE: З => 87 171‡ => ‡ 172 173CYRILLIC CAPITAL LETTER I: И => 88 174ˆ => ˆ 175 176CYRILLIC CAPITAL LETTER SHORT I: Й => 89 177‰ => ‰ 178 179CYRILLIC CAPITAL LETTER KA: К => 8a 180Š => Š 181 182CYRILLIC CAPITAL LETTER EL: Л => 8b 183‹ => ‹ 184 185CYRILLIC CAPITAL LETTER EM: М => 8c 186Œ => Œ 187 188CYRILLIC CAPITAL LETTER EN: Н => 8d 189 =>  190 191CYRILLIC CAPITAL LETTER O: О => 8e 192Ž => Ž 193 194CYRILLIC CAPITAL LETTER PE: П => 8f 195 =>  196 197CYRILLIC CAPITAL LETTER ER: Р => 90 198 =>  199 200CYRILLIC CAPITAL LETTER ES: С => 91 201‘ => ‘ 202 203CYRILLIC CAPITAL LETTER TE: Т => 92 204’ => ’ 205 206CYRILLIC CAPITAL LETTER U: У => 93 207“ => “ 208 209CYRILLIC CAPITAL LETTER EF: Ф => 94 210” => ” 211 212CYRILLIC CAPITAL LETTER HA: Х => 95 213• => • 214 215CYRILLIC CAPITAL LETTER TSE: Ц => 96 216– => – 217 218CYRILLIC CAPITAL LETTER CHE: Ч => 97 219— => — 220 221CYRILLIC CAPITAL LETTER SHA: Ш => 98 222˜ => ˜ 223 224CYRILLIC CAPITAL LETTER SHCHA: Щ => 99 225™ => ™ 226 227CYRILLIC CAPITAL LETTER HARD SIGN: Ъ => 9a 228š => š 229 230CYRILLIC CAPITAL LETTER YERU: Ы => 9b 231› => › 232 233CYRILLIC CAPITAL LETTER SOFT SIGN: Ь => 9c 234œ => œ 235 236CYRILLIC CAPITAL LETTER E: Э => 9d 237 =>  238 239CYRILLIC CAPITAL LETTER YU: Ю => 9e 240ž => ž 241 242CYRILLIC CAPITAL LETTER YA: Я => 9f 243Ÿ => Ÿ 244 245CYRILLIC SMALL LETTER A: а => a0 246  => ff 247 248CYRILLIC SMALL LETTER BE: б => a1 249¡ => ¡ 250 251CYRILLIC SMALL LETTER VE: в => a2 252¢ => ¢ 253 254CYRILLIC SMALL LETTER GHE: г => a3 255£ => £ 256 257CYRILLIC SMALL LETTER DE: д => a4 258¤ => fd 259 260CYRILLIC SMALL LETTER IE: е => a5 261¥ => ¥ 262 263CYRILLIC SMALL LETTER ZHE: ж => a6 264¦ => ¦ 265 266CYRILLIC SMALL LETTER ZE: з => a7 267§ => § 268 269CYRILLIC SMALL LETTER I: и => a8 270¨ => ¨ 271 272CYRILLIC SMALL LETTER SHORT I: й => a9 273© => © 274 275CYRILLIC SMALL LETTER KA: к => aa 276ª => ª 277 278CYRILLIC SMALL LETTER EL: л => ab 279« => « 280 281CYRILLIC SMALL LETTER EM: м => ac 282¬ => ¬ 283 284CYRILLIC SMALL LETTER EN: н => ad 285­ => ­ 286 287CYRILLIC SMALL LETTER O: о => ae 288® => ® 289 290CYRILLIC SMALL LETTER PE: п => af 291¯ => ¯ 292 293LIGHT SHADE: ░ => b0 294° => f8 295 296MEDIUM SHADE: ▒ => b1 297± => ± 298 299DARK SHADE: ▓ => b2 300² => ² 301 302BOX DRAWINGS LIGHT VERTICAL: │ => b3 303³ => ³ 304 305BOX DRAWINGS LIGHT VERTICAL AND LEFT: ┤ => b4 306´ => ´ 307 308BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE: ╡ => b5 309µ => µ 310 311BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE: ╢ => b6 312¶ => ¶ 313 314BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE: ╖ => b7 315· => fa 316 317BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE: ╕ => b8 318¸ => ¸ 319 320BOX DRAWINGS DOUBLE VERTICAL AND LEFT: ╣ => b9 321¹ => ¹ 322 323BOX DRAWINGS DOUBLE VERTICAL: ║ => ba 324º => º 325 326BOX DRAWINGS DOUBLE DOWN AND LEFT: ╗ => bb 327» => » 328 329BOX DRAWINGS DOUBLE UP AND LEFT: ╝ => bc 330¼ => ¼ 331 332BOX DRAWINGS UP DOUBLE AND LEFT SINGLE: ╜ => bd 333½ => ½ 334 335BOX DRAWINGS UP SINGLE AND LEFT DOUBLE: ╛ => be 336¾ => ¾ 337 338BOX DRAWINGS LIGHT DOWN AND LEFT: ┐ => bf 339¿ => ¿ 340 341BOX DRAWINGS LIGHT UP AND RIGHT: └ => c0 342À => À 343 344BOX DRAWINGS LIGHT UP AND HORIZONTAL: ┴ => c1 345Á => Á 346 347BOX DRAWINGS LIGHT DOWN AND HORIZONTAL: ┬ => c2 348 =>  349 350BOX DRAWINGS LIGHT VERTICAL AND RIGHT: ├ => c3 351à => à 352 353BOX DRAWINGS LIGHT HORIZONTAL: ─ => c4 354Ä => Ä 355 356BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL: ┼ => c5 357Å => Å 358 359BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE: ╞ => c6 360Æ => Æ 361 362BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE: ╟ => c7 363Ç => Ç 364 365BOX DRAWINGS DOUBLE UP AND RIGHT: ╚ => c8 366È => È 367 368BOX DRAWINGS DOUBLE DOWN AND RIGHT: ╔ => c9 369É => É 370 371BOX DRAWINGS DOUBLE UP AND HORIZONTAL: ╩ => ca 372Ê => Ê 373 374BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL: ╦ => cb 375Ë => Ë 376 377BOX DRAWINGS DOUBLE VERTICAL AND RIGHT: ╠ => cc 378Ì => Ì 379 380BOX DRAWINGS DOUBLE HORIZONTAL: ═ => cd 381Í => Í 382 383BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: ╬ => ce 384Î => Î 385 386BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE: ╧ => cf 387Ï => Ï 388 389BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE: ╨ => d0 390Ð => Ð 391 392BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE: ╤ => d1 393Ñ => Ñ 394 395BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE: ╥ => d2 396Ò => Ò 397 398BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE: ╙ => d3 399Ó => Ó 400 401BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE: ╘ => d4 402Ô => Ô 403 404BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE: ╒ => d5 405Õ => Õ 406 407BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE: ╓ => d6 408Ö => Ö 409 410BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE: ╫ => d7 411× => × 412 413BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE: ╪ => d8 414Ø => Ø 415 416BOX DRAWINGS LIGHT UP AND LEFT: ┘ => d9 417Ù => Ù 418 419BOX DRAWINGS LIGHT DOWN AND RIGHT: ┌ => da 420Ú => Ú 421 422FULL BLOCK: █ => db 423Û => Û 424 425LOWER HALF BLOCK: ▄ => dc 426Ü => Ü 427 428LEFT HALF BLOCK: ▌ => dd 429Ý => Ý 430 431RIGHT HALF BLOCK: ▐ => de 432Þ => Þ 433 434UPPER HALF BLOCK: ▀ => df 435ß => ß 436 437CYRILLIC SMALL LETTER ER: р => e0 438à => à 439 440CYRILLIC SMALL LETTER ES: с => e1 441á => á 442 443CYRILLIC SMALL LETTER TE: т => e2 444â => â 445 446CYRILLIC SMALL LETTER U: у => e3 447ã => ã 448 449CYRILLIC SMALL LETTER EF: ф => e4 450ä => ä 451 452CYRILLIC SMALL LETTER HA: х => e5 453å => å 454 455CYRILLIC SMALL LETTER TSE: ц => e6 456æ => æ 457 458CYRILLIC SMALL LETTER CHE: ч => e7 459ç => ç 460 461CYRILLIC SMALL LETTER SHA: ш => e8 462è => è 463 464CYRILLIC SMALL LETTER SHCHA: щ => e9 465é => é 466 467CYRILLIC SMALL LETTER HARD SIGN: ъ => ea 468ê => ê 469 470CYRILLIC SMALL LETTER YERU: ы => eb 471ë => ë 472 473CYRILLIC SMALL LETTER SOFT SIGN: ь => ec 474ì => ì 475 476CYRILLIC SMALL LETTER E: э => ed 477í => í 478 479CYRILLIC SMALL LETTER YU: ю => ee 480î => î 481 482CYRILLIC SMALL LETTER YA: я => ef 483ï => ï 484 485CYRILLIC CAPITAL LETTER IO: Ё => f0 486ð => ð 487 488CYRILLIC SMALL LETTER IO: ё => f1 489ñ => ñ 490 491CYRILLIC CAPITAL LETTER UKRAINIAN IE: Є => f2 492ò => ò 493 494CYRILLIC SMALL LETTER UKRAINIAN IE: є => f3 495ó => ó 496 497CYRILLIC CAPITAL LETTER YI: Ї => f4 498ô => ô 499 500CYRILLIC SMALL LETTER YI: ї => f5 501õ => õ 502 503CYRILLIC CAPITAL LETTER SHORT U: Ў => f6 504ö => ö 505 506CYRILLIC SMALL LETTER SHORT U: ў => f7 507÷ => ÷ 508 509DEGREE SIGN: ° => f8 510ø => ø 511 512BULLET OPERATOR: ∙ => f9 513ù => ù 514 515MIDDLE DOT: · => fa 516ú => ú 517 518SQUARE ROOT: √ => fb 519û => û 520 521NUMERO SIGN: № => fc 522ü => ü 523 524CURRENCY SIGN: ¤ => fd 525ý => ý 526 527BLACK SQUARE: ■ => fe 528þ => þ 529 530NO-BREAK SPACE:   => ff 531ÿ => ÿ 532