1--TEST-- 2Translation of HTML entities for encoding KOI8-R 3--FILE-- 4<?php 5$arr = array( 60x2500 => array(0x80, "BOX DRAWINGS LIGHT HORIZONTAL"), 70x2502 => array(0x81, "BOX DRAWINGS LIGHT VERTICAL"), 80x250C => array(0x82, "BOX DRAWINGS LIGHT DOWN AND RIGHT"), 90x2510 => array(0x83, "BOX DRAWINGS LIGHT DOWN AND LEFT"), 100x2514 => array(0x84, "BOX DRAWINGS LIGHT UP AND RIGHT"), 110x2518 => array(0x85, "BOX DRAWINGS LIGHT UP AND LEFT"), 120x251C => array(0x86, "BOX DRAWINGS LIGHT VERTICAL AND RIGHT"), 130x2524 => array(0x87, "BOX DRAWINGS LIGHT VERTICAL AND LEFT"), 140x252C => array(0x88, "BOX DRAWINGS LIGHT DOWN AND HORIZONTAL"), 150x2534 => array(0x89, "BOX DRAWINGS LIGHT UP AND HORIZONTAL"), 160x253C => array(0x8A, "BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL"), 170x2580 => array(0x8B, "UPPER HALF BLOCK"), 180x2584 => array(0x8C, "LOWER HALF BLOCK"), 190x2588 => array(0x8D, "FULL BLOCK"), 200x258C => array(0x8E, "LEFT HALF BLOCK"), 210x2590 => array(0x8F, "RIGHT HALF BLOCK"), 220x2591 => array(0x90, "LIGHT SHADE"), 230x2592 => array(0x91, "MEDIUM SHADE"), 240x2593 => array(0x92, "DARK SHADE"), 250x2320 => array(0x93, "TOP HALF INTEGRAL"), 260x25A0 => array(0x94, "BLACK SQUARE"), 270x2219 => array(0x95, "BULLET OPERATOR"), 280x221A => array(0x96, "SQUARE ROOT"), 290x2248 => array(0x97, "ALMOST EQUAL TO"), 300x2264 => array(0x98, "LESS-THAN OR EQUAL TO"), 310x2265 => array(0x99, "GREATER-THAN OR EQUAL TO"), 320x00A0 => array(0x9A, "NO-BREAK SPACE"), 330x2321 => array(0x9B, "BOTTOM HALF INTEGRAL"), 340x00B0 => array(0x9C, "DEGREE SIGN"), 350x00B2 => array(0x9D, "SUPERSCRIPT TWO"), 360x00B7 => array(0x9E, "MIDDLE DOT"), 370x00F7 => array(0x9F, "DIVISION SIGN"), 380x2550 => array(0xA0, "BOX DRAWINGS DOUBLE HORIZONTAL"), 390x2551 => array(0xA1, "BOX DRAWINGS DOUBLE VERTICAL"), 400x2552 => array(0xA2, "BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE"), 410x0451 => array(0xA3, "CYRILLIC SMALL LETTER IO"), 420x2553 => array(0xA4, "BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE"), 430x2554 => array(0xA5, "BOX DRAWINGS DOUBLE DOWN AND RIGHT"), 440x2555 => array(0xA6, "BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE"), 450x2556 => array(0xA7, "BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE"), 460x2557 => array(0xA8, "BOX DRAWINGS DOUBLE DOWN AND LEFT"), 470x2558 => array(0xA9, "BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE"), 480x2559 => array(0xAA, "BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE"), 490x255A => array(0xAB, "BOX DRAWINGS DOUBLE UP AND RIGHT"), 500x255B => array(0xAC, "BOX DRAWINGS UP SINGLE AND LEFT DOUBLE"), 510x255C => array(0xAD, "BOX DRAWINGS UP DOUBLE AND LEFT SINGLE"), 520x255D => array(0xAE, "BOX DRAWINGS DOUBLE UP AND LEFT"), 530x255E => array(0xAF, "BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE"), 540x255F => array(0xB0, "BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE"), 550x2560 => array(0xB1, "BOX DRAWINGS DOUBLE VERTICAL AND RIGHT"), 560x2561 => array(0xB2, "BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE"), 570x0401 => array(0xB3, "CYRILLIC CAPITAL LETTER IO"), 580x2562 => array(0xB4, "BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE"), 590x2563 => array(0xB5, "BOX DRAWINGS DOUBLE VERTICAL AND LEFT"), 600x2564 => array(0xB6, "BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE"), 610x2565 => array(0xB7, "BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE"), 620x2566 => array(0xB8, "BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL"), 630x2567 => array(0xB9, "BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE"), 640x2568 => array(0xBA, "BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE"), 650x2569 => array(0xBB, "BOX DRAWINGS DOUBLE UP AND HORIZONTAL"), 660x256A => array(0xBC, "BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE"), 670x256B => array(0xBD, "BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE"), 680x256C => array(0xBE, "BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL"), 690x00A9 => array(0xBF, "COPYRIGHT SIGN"), 700x044E => array(0xC0, "CYRILLIC SMALL LETTER YU"), 710x0430 => array(0xC1, "CYRILLIC SMALL LETTER A"), 720x0431 => array(0xC2, "CYRILLIC SMALL LETTER BE"), 730x0446 => array(0xC3, "CYRILLIC SMALL LETTER TSE"), 740x0434 => array(0xC4, "CYRILLIC SMALL LETTER DE"), 750x0435 => array(0xC5, "CYRILLIC SMALL LETTER IE"), 760x0444 => array(0xC6, "CYRILLIC SMALL LETTER EF"), 770x0433 => array(0xC7, "CYRILLIC SMALL LETTER GHE"), 780x0445 => array(0xC8, "CYRILLIC SMALL LETTER HA"), 790x0438 => array(0xC9, "CYRILLIC SMALL LETTER I"), 800x0439 => array(0xCA, "CYRILLIC SMALL LETTER SHORT I"), 810x043A => array(0xCB, "CYRILLIC SMALL LETTER KA"), 820x043B => array(0xCC, "CYRILLIC SMALL LETTER EL"), 830x043C => array(0xCD, "CYRILLIC SMALL LETTER EM"), 840x043D => array(0xCE, "CYRILLIC SMALL LETTER EN"), 850x043E => array(0xCF, "CYRILLIC SMALL LETTER O"), 860x043F => array(0xD0, "CYRILLIC SMALL LETTER PE"), 870x044F => array(0xD1, "CYRILLIC SMALL LETTER YA"), 880x0440 => array(0xD2, "CYRILLIC SMALL LETTER ER"), 890x0441 => array(0xD3, "CYRILLIC SMALL LETTER ES"), 900x0442 => array(0xD4, "CYRILLIC SMALL LETTER TE"), 910x0443 => array(0xD5, "CYRILLIC SMALL LETTER U"), 920x0436 => array(0xD6, "CYRILLIC SMALL LETTER ZHE"), 930x0432 => array(0xD7, "CYRILLIC SMALL LETTER VE"), 940x044C => array(0xD8, "CYRILLIC SMALL LETTER SOFT SIGN"), 950x044B => array(0xD9, "CYRILLIC SMALL LETTER YERU"), 960x0437 => array(0xDA, "CYRILLIC SMALL LETTER ZE"), 970x0448 => array(0xDB, "CYRILLIC SMALL LETTER SHA"), 980x044D => array(0xDC, "CYRILLIC SMALL LETTER E"), 990x0449 => array(0xDD, "CYRILLIC SMALL LETTER SHCHA"), 1000x0447 => array(0xDE, "CYRILLIC SMALL LETTER CHE"), 1010x044A => array(0xDF, "CYRILLIC SMALL LETTER HARD SIGN"), 1020x042E => array(0xE0, "CYRILLIC CAPITAL LETTER YU"), 1030x0410 => array(0xE1, "CYRILLIC CAPITAL LETTER A"), 1040x0411 => array(0xE2, "CYRILLIC CAPITAL LETTER BE"), 1050x0426 => array(0xE3, "CYRILLIC CAPITAL LETTER TSE"), 1060x0414 => array(0xE4, "CYRILLIC CAPITAL LETTER DE"), 1070x0415 => array(0xE5, "CYRILLIC CAPITAL LETTER IE"), 1080x0424 => array(0xE6, "CYRILLIC CAPITAL LETTER EF"), 1090x0413 => array(0xE7, "CYRILLIC CAPITAL LETTER GHE"), 1100x0425 => array(0xE8, "CYRILLIC CAPITAL LETTER HA"), 1110x0418 => array(0xE9, "CYRILLIC CAPITAL LETTER I"), 1120x0419 => array(0xEA, "CYRILLIC CAPITAL LETTER SHORT I"), 1130x041A => array(0xEB, "CYRILLIC CAPITAL LETTER KA"), 1140x041B => array(0xEC, "CYRILLIC CAPITAL LETTER EL"), 1150x041C => array(0xED, "CYRILLIC CAPITAL LETTER EM"), 1160x041D => array(0xEE, "CYRILLIC CAPITAL LETTER EN"), 1170x041E => array(0xEF, "CYRILLIC CAPITAL LETTER O"), 1180x041F => array(0xF0, "CYRILLIC CAPITAL LETTER PE"), 1190x042F => array(0xF1, "CYRILLIC CAPITAL LETTER YA"), 1200x0420 => array(0xF2, "CYRILLIC CAPITAL LETTER ER"), 1210x0421 => array(0xF3, "CYRILLIC CAPITAL LETTER ES"), 1220x0422 => array(0xF4, "CYRILLIC CAPITAL LETTER TE"), 1230x0423 => array(0xF5, "CYRILLIC CAPITAL LETTER U"), 1240x0416 => array(0xF6, "CYRILLIC CAPITAL LETTER ZHE"), 1250x0412 => array(0xF7, "CYRILLIC CAPITAL LETTER VE"), 1260x042C => array(0xF8, "CYRILLIC CAPITAL LETTER SOFT SIGN"), 1270x042B => array(0xF9, "CYRILLIC CAPITAL LETTER YERU"), 1280x0417 => array(0xFA, "CYRILLIC CAPITAL LETTER ZE"), 1290x0428 => array(0xFB, "CYRILLIC CAPITAL LETTER SHA"), 1300x042D => array(0xFC, "CYRILLIC CAPITAL LETTER E"), 1310x0429 => array(0xFD, "CYRILLIC CAPITAL LETTER SHCHA"), 1320x0427 => array(0xFE, "CYRILLIC CAPITAL LETTER CHE"), 1330x042A => array(0xFF, "CYRILLIC CAPITAL LETTER HARD SIGN"), 134); 135 136foreach ($arr as $u => $v) { 137 $ent = sprintf("&#x%X;", $u); 138 $res = html_entity_decode($ent, ENT_QUOTES, 'KOI8-R'); 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, 'KOI8-R'); 144 if ($res[0] != "&" || $res[1] != "#") 145 $res = unpack("H*", $res)[1]; 146 echo sprintf("%s => %s\n\n", $ent, $res); 147} 148--EXPECT-- 149BOX DRAWINGS LIGHT HORIZONTAL: ─ => 80 150€ => € 151 152BOX DRAWINGS LIGHT VERTICAL: │ => 81 153 =>  154 155BOX DRAWINGS LIGHT DOWN AND RIGHT: ┌ => 82 156‚ => ‚ 157 158BOX DRAWINGS LIGHT DOWN AND LEFT: ┐ => 83 159ƒ => ƒ 160 161BOX DRAWINGS LIGHT UP AND RIGHT: └ => 84 162„ => „ 163 164BOX DRAWINGS LIGHT UP AND LEFT: ┘ => 85 165… => … 166 167BOX DRAWINGS LIGHT VERTICAL AND RIGHT: ├ => 86 168† => † 169 170BOX DRAWINGS LIGHT VERTICAL AND LEFT: ┤ => 87 171‡ => ‡ 172 173BOX DRAWINGS LIGHT DOWN AND HORIZONTAL: ┬ => 88 174ˆ => ˆ 175 176BOX DRAWINGS LIGHT UP AND HORIZONTAL: ┴ => 89 177‰ => ‰ 178 179BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL: ┼ => 8a 180Š => Š 181 182UPPER HALF BLOCK: ▀ => 8b 183‹ => ‹ 184 185LOWER HALF BLOCK: ▄ => 8c 186Œ => Œ 187 188FULL BLOCK: █ => 8d 189 =>  190 191LEFT HALF BLOCK: ▌ => 8e 192Ž => Ž 193 194RIGHT HALF BLOCK: ▐ => 8f 195 =>  196 197LIGHT SHADE: ░ => 90 198 =>  199 200MEDIUM SHADE: ▒ => 91 201‘ => ‘ 202 203DARK SHADE: ▓ => 92 204’ => ’ 205 206TOP HALF INTEGRAL: ⌠ => 93 207“ => “ 208 209BLACK SQUARE: ■ => 94 210” => ” 211 212BULLET OPERATOR: ∙ => 95 213• => • 214 215SQUARE ROOT: √ => 96 216– => – 217 218ALMOST EQUAL TO: ≈ => 97 219— => — 220 221LESS-THAN OR EQUAL TO: ≤ => 98 222˜ => ˜ 223 224GREATER-THAN OR EQUAL TO: ≥ => 99 225™ => ™ 226 227NO-BREAK SPACE:   => 9a 228š => š 229 230BOTTOM HALF INTEGRAL: ⌡ => 9b 231› => › 232 233DEGREE SIGN: ° => 9c 234œ => œ 235 236SUPERSCRIPT TWO: ² => 9d 237 =>  238 239MIDDLE DOT: · => 9e 240ž => ž 241 242DIVISION SIGN: ÷ => 9f 243Ÿ => Ÿ 244 245BOX DRAWINGS DOUBLE HORIZONTAL: ═ => a0 246  => 9a 247 248BOX DRAWINGS DOUBLE VERTICAL: ║ => a1 249¡ => ¡ 250 251BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE: ╒ => a2 252¢ => ¢ 253 254CYRILLIC SMALL LETTER IO: ё => a3 255£ => £ 256 257BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE: ╓ => a4 258¤ => ¤ 259 260BOX DRAWINGS DOUBLE DOWN AND RIGHT: ╔ => a5 261¥ => ¥ 262 263BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE: ╕ => a6 264¦ => ¦ 265 266BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE: ╖ => a7 267§ => § 268 269BOX DRAWINGS DOUBLE DOWN AND LEFT: ╗ => a8 270¨ => ¨ 271 272BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE: ╘ => a9 273© => bf 274 275BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE: ╙ => aa 276ª => ª 277 278BOX DRAWINGS DOUBLE UP AND RIGHT: ╚ => ab 279« => « 280 281BOX DRAWINGS UP SINGLE AND LEFT DOUBLE: ╛ => ac 282¬ => ¬ 283 284BOX DRAWINGS UP DOUBLE AND LEFT SINGLE: ╜ => ad 285­ => ­ 286 287BOX DRAWINGS DOUBLE UP AND LEFT: ╝ => ae 288® => ® 289 290BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE: ╞ => af 291¯ => ¯ 292 293BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE: ╟ => b0 294° => 9c 295 296BOX DRAWINGS DOUBLE VERTICAL AND RIGHT: ╠ => b1 297± => ± 298 299BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE: ╡ => b2 300² => 9d 301 302CYRILLIC CAPITAL LETTER IO: Ё => b3 303³ => ³ 304 305BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE: ╢ => b4 306´ => ´ 307 308BOX DRAWINGS DOUBLE VERTICAL AND LEFT: ╣ => b5 309µ => µ 310 311BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE: ╤ => b6 312¶ => ¶ 313 314BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE: ╥ => b7 315· => 9e 316 317BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL: ╦ => b8 318¸ => ¸ 319 320BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE: ╧ => b9 321¹ => ¹ 322 323BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE: ╨ => ba 324º => º 325 326BOX DRAWINGS DOUBLE UP AND HORIZONTAL: ╩ => bb 327» => » 328 329BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE: ╪ => bc 330¼ => ¼ 331 332BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE: ╫ => bd 333½ => ½ 334 335BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: ╬ => be 336¾ => ¾ 337 338COPYRIGHT SIGN: © => bf 339¿ => ¿ 340 341CYRILLIC SMALL LETTER YU: ю => c0 342À => À 343 344CYRILLIC SMALL LETTER A: а => c1 345Á => Á 346 347CYRILLIC SMALL LETTER BE: б => c2 348 =>  349 350CYRILLIC SMALL LETTER TSE: ц => c3 351à => à 352 353CYRILLIC SMALL LETTER DE: д => c4 354Ä => Ä 355 356CYRILLIC SMALL LETTER IE: е => c5 357Å => Å 358 359CYRILLIC SMALL LETTER EF: ф => c6 360Æ => Æ 361 362CYRILLIC SMALL LETTER GHE: г => c7 363Ç => Ç 364 365CYRILLIC SMALL LETTER HA: х => c8 366È => È 367 368CYRILLIC SMALL LETTER I: и => c9 369É => É 370 371CYRILLIC SMALL LETTER SHORT I: й => ca 372Ê => Ê 373 374CYRILLIC SMALL LETTER KA: к => cb 375Ë => Ë 376 377CYRILLIC SMALL LETTER EL: л => cc 378Ì => Ì 379 380CYRILLIC SMALL LETTER EM: м => cd 381Í => Í 382 383CYRILLIC SMALL LETTER EN: н => ce 384Î => Î 385 386CYRILLIC SMALL LETTER O: о => cf 387Ï => Ï 388 389CYRILLIC SMALL LETTER PE: п => d0 390Ð => Ð 391 392CYRILLIC SMALL LETTER YA: я => d1 393Ñ => Ñ 394 395CYRILLIC SMALL LETTER ER: р => d2 396Ò => Ò 397 398CYRILLIC SMALL LETTER ES: с => d3 399Ó => Ó 400 401CYRILLIC SMALL LETTER TE: т => d4 402Ô => Ô 403 404CYRILLIC SMALL LETTER U: у => d5 405Õ => Õ 406 407CYRILLIC SMALL LETTER ZHE: ж => d6 408Ö => Ö 409 410CYRILLIC SMALL LETTER VE: в => d7 411× => × 412 413CYRILLIC SMALL LETTER SOFT SIGN: ь => d8 414Ø => Ø 415 416CYRILLIC SMALL LETTER YERU: ы => d9 417Ù => Ù 418 419CYRILLIC SMALL LETTER ZE: з => da 420Ú => Ú 421 422CYRILLIC SMALL LETTER SHA: ш => db 423Û => Û 424 425CYRILLIC SMALL LETTER E: э => dc 426Ü => Ü 427 428CYRILLIC SMALL LETTER SHCHA: щ => dd 429Ý => Ý 430 431CYRILLIC SMALL LETTER CHE: ч => de 432Þ => Þ 433 434CYRILLIC SMALL LETTER HARD SIGN: ъ => df 435ß => ß 436 437CYRILLIC CAPITAL LETTER YU: Ю => e0 438à => à 439 440CYRILLIC CAPITAL LETTER A: А => e1 441á => á 442 443CYRILLIC CAPITAL LETTER BE: Б => e2 444â => â 445 446CYRILLIC CAPITAL LETTER TSE: Ц => e3 447ã => ã 448 449CYRILLIC CAPITAL LETTER DE: Д => e4 450ä => ä 451 452CYRILLIC CAPITAL LETTER IE: Е => e5 453å => å 454 455CYRILLIC CAPITAL LETTER EF: Ф => e6 456æ => æ 457 458CYRILLIC CAPITAL LETTER GHE: Г => e7 459ç => ç 460 461CYRILLIC CAPITAL LETTER HA: Х => e8 462è => è 463 464CYRILLIC CAPITAL LETTER I: И => e9 465é => é 466 467CYRILLIC CAPITAL LETTER SHORT I: Й => ea 468ê => ê 469 470CYRILLIC CAPITAL LETTER KA: К => eb 471ë => ë 472 473CYRILLIC CAPITAL LETTER EL: Л => ec 474ì => ì 475 476CYRILLIC CAPITAL LETTER EM: М => ed 477í => í 478 479CYRILLIC CAPITAL LETTER EN: Н => ee 480î => î 481 482CYRILLIC CAPITAL LETTER O: О => ef 483ï => ï 484 485CYRILLIC CAPITAL LETTER PE: П => f0 486ð => ð 487 488CYRILLIC CAPITAL LETTER YA: Я => f1 489ñ => ñ 490 491CYRILLIC CAPITAL LETTER ER: Р => f2 492ò => ò 493 494CYRILLIC CAPITAL LETTER ES: С => f3 495ó => ó 496 497CYRILLIC CAPITAL LETTER TE: Т => f4 498ô => ô 499 500CYRILLIC CAPITAL LETTER U: У => f5 501õ => õ 502 503CYRILLIC CAPITAL LETTER ZHE: Ж => f6 504ö => ö 505 506CYRILLIC CAPITAL LETTER VE: В => f7 507÷ => 9f 508 509CYRILLIC CAPITAL LETTER SOFT SIGN: Ь => f8 510ø => ø 511 512CYRILLIC CAPITAL LETTER YERU: Ы => f9 513ù => ù 514 515CYRILLIC CAPITAL LETTER ZE: З => fa 516ú => ú 517 518CYRILLIC CAPITAL LETTER SHA: Ш => fb 519û => û 520 521CYRILLIC CAPITAL LETTER E: Э => fc 522ü => ü 523 524CYRILLIC CAPITAL LETTER SHCHA: Щ => fd 525ý => ý 526 527CYRILLIC CAPITAL LETTER CHE: Ч => fe 528þ => þ 529 530CYRILLIC CAPITAL LETTER HARD SIGN: Ъ => ff 531ÿ => ÿ 532