1--TEST-- 2Translation of HTML entities for encoding WIN-1251 3--FILE-- 4<?php 5$arr = array( 60x0402 => array(0x80, "CYRILLIC CAPITAL LETTER DJE"), 70x0403 => array(0x81, "CYRILLIC CAPITAL LETTER GJE"), 80x201A => array(0x82, "SINGLE LOW-9 QUOTATION MARK"), 90x0453 => array(0x83, "CYRILLIC SMALL LETTER GJE"), 100x201E => array(0x84, "DOUBLE LOW-9 QUOTATION MARK"), 110x2026 => array(0x85, "HORIZONTAL ELLIPSIS"), 120x2020 => array(0x86, "DAGGER"), 130x2021 => array(0x87, "DOUBLE DAGGER"), 140x20AC => array(0x88, "EURO SIGN"), 150x2030 => array(0x89, "PER MILLE SIGN"), 160x0409 => array(0x8A, "CYRILLIC CAPITAL LETTER LJE"), 170x2039 => array(0x8B, "SINGLE LEFT-POINTING ANGLE QUOTATION MARK"), 180x040A => array(0x8C, "CYRILLIC CAPITAL LETTER NJE"), 190x040C => array(0x8D, "CYRILLIC CAPITAL LETTER KJE"), 200x040B => array(0x8E, "CYRILLIC CAPITAL LETTER TSHE"), 210x040F => array(0x8F, "CYRILLIC CAPITAL LETTER DZHE"), 220x0452 => array(0x90, "CYRILLIC SMALL LETTER DJE"), 230x2018 => array(0x91, "LEFT SINGLE QUOTATION MARK"), 240x2019 => array(0x92, "RIGHT SINGLE QUOTATION MARK"), 250x201C => array(0x93, "LEFT DOUBLE QUOTATION MARK"), 260x201D => array(0x94, "RIGHT DOUBLE QUOTATION MARK"), 270x2022 => array(0x95, "BULLET"), 280x2013 => array(0x96, "EN DASH"), 290x2014 => array(0x97, "EM DASH"), 30//0x98 #UNDEFINED 310x2122 => array(0x99, "TRADE MARK SIGN"), 320x0459 => array(0x9A, "CYRILLIC SMALL LETTER LJE"), 330x203A => array(0x9B, "SINGLE RIGHT-POINTING ANGLE QUOTATION MARK"), 340x045A => array(0x9C, "CYRILLIC SMALL LETTER NJE"), 350x045C => array(0x9D, "CYRILLIC SMALL LETTER KJE"), 360x045B => array(0x9E, "CYRILLIC SMALL LETTER TSHE"), 370x045F => array(0x9F, "CYRILLIC SMALL LETTER DZHE"), 380x00A0 => array(0xA0, "NO-BREAK SPACE"), 390x040E => array(0xA1, "CYRILLIC CAPITAL LETTER SHORT U"), 400x045E => array(0xA2, "CYRILLIC SMALL LETTER SHORT U"), 410x0408 => array(0xA3, "CYRILLIC CAPITAL LETTER JE"), 420x00A4 => array(0xA4, "CURRENCY SIGN"), 430x0490 => array(0xA5, "CYRILLIC CAPITAL LETTER GHE WITH UPTURN"), 440x00A6 => array(0xA6, "BROKEN BAR"), 450x00A7 => array(0xA7, "SECTION SIGN"), 460x0401 => array(0xA8, "CYRILLIC CAPITAL LETTER IO"), 470x00A9 => array(0xA9, "COPYRIGHT SIGN"), 480x0404 => array(0xAA, "CYRILLIC CAPITAL LETTER UKRAINIAN IE"), 490x00AB => array(0xAB, "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK"), 500x00AC => array(0xAC, "NOT SIGN"), 510x00AD => array(0xAD, "SOFT HYPHEN"), 520x00AE => array(0xAE, "REGISTERED SIGN"), 530x0407 => array(0xAF, "CYRILLIC CAPITAL LETTER YI"), 540x00B0 => array(0xB0, "DEGREE SIGN"), 550x00B1 => array(0xB1, "PLUS-MINUS SIGN"), 560x0406 => array(0xB2, "CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I"), 570x0456 => array(0xB3, "CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I"), 580x0491 => array(0xB4, "CYRILLIC SMALL LETTER GHE WITH UPTURN"), 590x00B5 => array(0xB5, "MICRO SIGN"), 600x00B6 => array(0xB6, "PILCROW SIGN"), 610x00B7 => array(0xB7, "MIDDLE DOT"), 620x0451 => array(0xB8, "CYRILLIC SMALL LETTER IO"), 630x2116 => array(0xB9, "NUMERO SIGN"), 640x0454 => array(0xBA, "CYRILLIC SMALL LETTER UKRAINIAN IE"), 650x00BB => array(0xBB, "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK"), 660x0458 => array(0xBC, "CYRILLIC SMALL LETTER JE"), 670x0405 => array(0xBD, "CYRILLIC CAPITAL LETTER DZE"), 680x0455 => array(0xBE, "CYRILLIC SMALL LETTER DZE"), 690x0457 => array(0xBF, "CYRILLIC SMALL LETTER YI"), 700x0410 => array(0xC0, "CYRILLIC CAPITAL LETTER A"), 710x0411 => array(0xC1, "CYRILLIC CAPITAL LETTER BE"), 720x0412 => array(0xC2, "CYRILLIC CAPITAL LETTER VE"), 730x0413 => array(0xC3, "CYRILLIC CAPITAL LETTER GHE"), 740x0414 => array(0xC4, "CYRILLIC CAPITAL LETTER DE"), 750x0415 => array(0xC5, "CYRILLIC CAPITAL LETTER IE"), 760x0416 => array(0xC6, "CYRILLIC CAPITAL LETTER ZHE"), 770x0417 => array(0xC7, "CYRILLIC CAPITAL LETTER ZE"), 780x0418 => array(0xC8, "CYRILLIC CAPITAL LETTER I"), 790x0419 => array(0xC9, "CYRILLIC CAPITAL LETTER SHORT I"), 800x041A => array(0xCA, "CYRILLIC CAPITAL LETTER KA"), 810x041B => array(0xCB, "CYRILLIC CAPITAL LETTER EL"), 820x041C => array(0xCC, "CYRILLIC CAPITAL LETTER EM"), 830x041D => array(0xCD, "CYRILLIC CAPITAL LETTER EN"), 840x041E => array(0xCE, "CYRILLIC CAPITAL LETTER O"), 850x041F => array(0xCF, "CYRILLIC CAPITAL LETTER PE"), 860x0420 => array(0xD0, "CYRILLIC CAPITAL LETTER ER"), 870x0421 => array(0xD1, "CYRILLIC CAPITAL LETTER ES"), 880x0422 => array(0xD2, "CYRILLIC CAPITAL LETTER TE"), 890x0423 => array(0xD3, "CYRILLIC CAPITAL LETTER U"), 900x0424 => array(0xD4, "CYRILLIC CAPITAL LETTER EF"), 910x0425 => array(0xD5, "CYRILLIC CAPITAL LETTER HA"), 920x0426 => array(0xD6, "CYRILLIC CAPITAL LETTER TSE"), 930x0427 => array(0xD7, "CYRILLIC CAPITAL LETTER CHE"), 940x0428 => array(0xD8, "CYRILLIC CAPITAL LETTER SHA"), 950x0429 => array(0xD9, "CYRILLIC CAPITAL LETTER SHCHA"), 960x042A => array(0xDA, "CYRILLIC CAPITAL LETTER HARD SIGN"), 970x042B => array(0xDB, "CYRILLIC CAPITAL LETTER YERU"), 980x042C => array(0xDC, "CYRILLIC CAPITAL LETTER SOFT SIGN"), 990x042D => array(0xDD, "CYRILLIC CAPITAL LETTER E"), 1000x042E => array(0xDE, "CYRILLIC CAPITAL LETTER YU"), 1010x042F => array(0xDF, "CYRILLIC CAPITAL LETTER YA"), 1020x0430 => array(0xE0, "CYRILLIC SMALL LETTER A"), 1030x0431 => array(0xE1, "CYRILLIC SMALL LETTER BE"), 1040x0432 => array(0xE2, "CYRILLIC SMALL LETTER VE"), 1050x0433 => array(0xE3, "CYRILLIC SMALL LETTER GHE"), 1060x0434 => array(0xE4, "CYRILLIC SMALL LETTER DE"), 1070x0435 => array(0xE5, "CYRILLIC SMALL LETTER IE"), 1080x0436 => array(0xE6, "CYRILLIC SMALL LETTER ZHE"), 1090x0437 => array(0xE7, "CYRILLIC SMALL LETTER ZE"), 1100x0438 => array(0xE8, "CYRILLIC SMALL LETTER I"), 1110x0439 => array(0xE9, "CYRILLIC SMALL LETTER SHORT I"), 1120x043A => array(0xEA, "CYRILLIC SMALL LETTER KA"), 1130x043B => array(0xEB, "CYRILLIC SMALL LETTER EL"), 1140x043C => array(0xEC, "CYRILLIC SMALL LETTER EM"), 1150x043D => array(0xED, "CYRILLIC SMALL LETTER EN"), 1160x043E => array(0xEE, "CYRILLIC SMALL LETTER O"), 1170x043F => array(0xEF, "CYRILLIC SMALL LETTER PE"), 1180x0440 => array(0xF0, "CYRILLIC SMALL LETTER ER"), 1190x0441 => array(0xF1, "CYRILLIC SMALL LETTER ES"), 1200x0442 => array(0xF2, "CYRILLIC SMALL LETTER TE"), 1210x0443 => array(0xF3, "CYRILLIC SMALL LETTER U"), 1220x0444 => array(0xF4, "CYRILLIC SMALL LETTER EF"), 1230x0445 => array(0xF5, "CYRILLIC SMALL LETTER HA"), 1240x0446 => array(0xF6, "CYRILLIC SMALL LETTER TSE"), 1250x0447 => array(0xF7, "CYRILLIC SMALL LETTER CHE"), 1260x0448 => array(0xF8, "CYRILLIC SMALL LETTER SHA"), 1270x0449 => array(0xF9, "CYRILLIC SMALL LETTER SHCHA"), 1280x044A => array(0xFA, "CYRILLIC SMALL LETTER HARD SIGN"), 1290x044B => array(0xFB, "CYRILLIC SMALL LETTER YERU"), 1300x044C => array(0xFC, "CYRILLIC SMALL LETTER SOFT SIGN"), 1310x044D => array(0xFD, "CYRILLIC SMALL LETTER E"), 1320x044E => array(0xFE, "CYRILLIC SMALL LETTER YU"), 1330x044F => array(0xFF, "CYRILLIC SMALL LETTER YA"), 134); 135 136$res = html_entity_decode("˜", ENT_QUOTES, 'WINDOWS-1251'); 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, 'WINDOWS-1251'); 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, 'WINDOWS-1251'); 148 if ($res[0] != "&" || $res[1] != "#") 149 $res = unpack("H*", $res)[1]; 150 echo sprintf("%s => %s\n\n", $ent, $res); 151} 152?> 153--EXPECT-- 154Special test for ˜ (shouldn't decode): 155˜ 156 157CYRILLIC CAPITAL LETTER DJE: Ђ => 80 158€ => € 159 160CYRILLIC CAPITAL LETTER GJE: Ѓ => 81 161 =>  162 163SINGLE LOW-9 QUOTATION MARK: ‚ => 82 164‚ => ‚ 165 166CYRILLIC SMALL LETTER GJE: ѓ => 83 167ƒ => ƒ 168 169DOUBLE LOW-9 QUOTATION MARK: „ => 84 170„ => „ 171 172HORIZONTAL ELLIPSIS: … => 85 173… => … 174 175DAGGER: † => 86 176† => † 177 178DOUBLE DAGGER: ‡ => 87 179‡ => ‡ 180 181EURO SIGN: € => 88 182ˆ => ˆ 183 184PER MILLE SIGN: ‰ => 89 185‰ => ‰ 186 187CYRILLIC CAPITAL LETTER LJE: Љ => 8a 188Š => Š 189 190SINGLE LEFT-POINTING ANGLE QUOTATION MARK: ‹ => 8b 191‹ => ‹ 192 193CYRILLIC CAPITAL LETTER NJE: Њ => 8c 194Œ => Œ 195 196CYRILLIC CAPITAL LETTER KJE: Ќ => 8d 197 =>  198 199CYRILLIC CAPITAL LETTER TSHE: Ћ => 8e 200Ž => Ž 201 202CYRILLIC CAPITAL LETTER DZHE: Џ => 8f 203 =>  204 205CYRILLIC SMALL LETTER DJE: ђ => 90 206 =>  207 208LEFT SINGLE QUOTATION MARK: ‘ => 91 209‘ => ‘ 210 211RIGHT SINGLE QUOTATION MARK: ’ => 92 212’ => ’ 213 214LEFT DOUBLE QUOTATION MARK: “ => 93 215“ => “ 216 217RIGHT DOUBLE QUOTATION MARK: ” => 94 218” => ” 219 220BULLET: • => 95 221• => • 222 223EN DASH: – => 96 224– => – 225 226EM DASH: — => 97 227— => — 228 229TRADE MARK SIGN: ™ => 99 230™ => ™ 231 232CYRILLIC SMALL LETTER LJE: љ => 9a 233š => š 234 235SINGLE RIGHT-POINTING ANGLE QUOTATION MARK: › => 9b 236› => › 237 238CYRILLIC SMALL LETTER NJE: њ => 9c 239œ => œ 240 241CYRILLIC SMALL LETTER KJE: ќ => 9d 242 =>  243 244CYRILLIC SMALL LETTER TSHE: ћ => 9e 245ž => ž 246 247CYRILLIC SMALL LETTER DZHE: џ => 9f 248Ÿ => Ÿ 249 250NO-BREAK SPACE:   => a0 251  => a0 252 253CYRILLIC CAPITAL LETTER SHORT U: Ў => a1 254¡ => ¡ 255 256CYRILLIC SMALL LETTER SHORT U: ў => a2 257¢ => ¢ 258 259CYRILLIC CAPITAL LETTER JE: Ј => a3 260£ => £ 261 262CURRENCY SIGN: ¤ => a4 263¤ => a4 264 265CYRILLIC CAPITAL LETTER GHE WITH UPTURN: Ґ => a5 266¥ => ¥ 267 268BROKEN BAR: ¦ => a6 269¦ => a6 270 271SECTION SIGN: § => a7 272§ => a7 273 274CYRILLIC CAPITAL LETTER IO: Ё => a8 275¨ => ¨ 276 277COPYRIGHT SIGN: © => a9 278© => a9 279 280CYRILLIC CAPITAL LETTER UKRAINIAN IE: Є => aa 281ª => ª 282 283LEFT-POINTING DOUBLE ANGLE QUOTATION MARK: « => ab 284« => ab 285 286NOT SIGN: ¬ => ac 287¬ => ac 288 289SOFT HYPHEN: ­ => ad 290­ => ad 291 292REGISTERED SIGN: ® => ae 293® => ae 294 295CYRILLIC CAPITAL LETTER YI: Ї => af 296¯ => ¯ 297 298DEGREE SIGN: ° => b0 299° => b0 300 301PLUS-MINUS SIGN: ± => b1 302± => b1 303 304CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I: І => b2 305² => ² 306 307CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I: і => b3 308³ => ³ 309 310CYRILLIC SMALL LETTER GHE WITH UPTURN: ґ => b4 311´ => ´ 312 313MICRO SIGN: µ => b5 314µ => b5 315 316PILCROW SIGN: ¶ => b6 317¶ => b6 318 319MIDDLE DOT: · => b7 320· => b7 321 322CYRILLIC SMALL LETTER IO: ё => b8 323¸ => ¸ 324 325NUMERO SIGN: № => b9 326¹ => ¹ 327 328CYRILLIC SMALL LETTER UKRAINIAN IE: є => ba 329º => º 330 331RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK: » => bb 332» => bb 333 334CYRILLIC SMALL LETTER JE: ј => bc 335¼ => ¼ 336 337CYRILLIC CAPITAL LETTER DZE: Ѕ => bd 338½ => ½ 339 340CYRILLIC SMALL LETTER DZE: ѕ => be 341¾ => ¾ 342 343CYRILLIC SMALL LETTER YI: ї => bf 344¿ => ¿ 345 346CYRILLIC CAPITAL LETTER A: А => c0 347À => À 348 349CYRILLIC CAPITAL LETTER BE: Б => c1 350Á => Á 351 352CYRILLIC CAPITAL LETTER VE: В => c2 353 =>  354 355CYRILLIC CAPITAL LETTER GHE: Г => c3 356à => à 357 358CYRILLIC CAPITAL LETTER DE: Д => c4 359Ä => Ä 360 361CYRILLIC CAPITAL LETTER IE: Е => c5 362Å => Å 363 364CYRILLIC CAPITAL LETTER ZHE: Ж => c6 365Æ => Æ 366 367CYRILLIC CAPITAL LETTER ZE: З => c7 368Ç => Ç 369 370CYRILLIC CAPITAL LETTER I: И => c8 371È => È 372 373CYRILLIC CAPITAL LETTER SHORT I: Й => c9 374É => É 375 376CYRILLIC CAPITAL LETTER KA: К => ca 377Ê => Ê 378 379CYRILLIC CAPITAL LETTER EL: Л => cb 380Ë => Ë 381 382CYRILLIC CAPITAL LETTER EM: М => cc 383Ì => Ì 384 385CYRILLIC CAPITAL LETTER EN: Н => cd 386Í => Í 387 388CYRILLIC CAPITAL LETTER O: О => ce 389Î => Î 390 391CYRILLIC CAPITAL LETTER PE: П => cf 392Ï => Ï 393 394CYRILLIC CAPITAL LETTER ER: Р => d0 395Ð => Ð 396 397CYRILLIC CAPITAL LETTER ES: С => d1 398Ñ => Ñ 399 400CYRILLIC CAPITAL LETTER TE: Т => d2 401Ò => Ò 402 403CYRILLIC CAPITAL LETTER U: У => d3 404Ó => Ó 405 406CYRILLIC CAPITAL LETTER EF: Ф => d4 407Ô => Ô 408 409CYRILLIC CAPITAL LETTER HA: Х => d5 410Õ => Õ 411 412CYRILLIC CAPITAL LETTER TSE: Ц => d6 413Ö => Ö 414 415CYRILLIC CAPITAL LETTER CHE: Ч => d7 416× => × 417 418CYRILLIC CAPITAL LETTER SHA: Ш => d8 419Ø => Ø 420 421CYRILLIC CAPITAL LETTER SHCHA: Щ => d9 422Ù => Ù 423 424CYRILLIC CAPITAL LETTER HARD SIGN: Ъ => da 425Ú => Ú 426 427CYRILLIC CAPITAL LETTER YERU: Ы => db 428Û => Û 429 430CYRILLIC CAPITAL LETTER SOFT SIGN: Ь => dc 431Ü => Ü 432 433CYRILLIC CAPITAL LETTER E: Э => dd 434Ý => Ý 435 436CYRILLIC CAPITAL LETTER YU: Ю => de 437Þ => Þ 438 439CYRILLIC CAPITAL LETTER YA: Я => df 440ß => ß 441 442CYRILLIC SMALL LETTER A: а => e0 443à => à 444 445CYRILLIC SMALL LETTER BE: б => e1 446á => á 447 448CYRILLIC SMALL LETTER VE: в => e2 449â => â 450 451CYRILLIC SMALL LETTER GHE: г => e3 452ã => ã 453 454CYRILLIC SMALL LETTER DE: д => e4 455ä => ä 456 457CYRILLIC SMALL LETTER IE: е => e5 458å => å 459 460CYRILLIC SMALL LETTER ZHE: ж => e6 461æ => æ 462 463CYRILLIC SMALL LETTER ZE: з => e7 464ç => ç 465 466CYRILLIC SMALL LETTER I: и => e8 467è => è 468 469CYRILLIC SMALL LETTER SHORT I: й => e9 470é => é 471 472CYRILLIC SMALL LETTER KA: к => ea 473ê => ê 474 475CYRILLIC SMALL LETTER EL: л => eb 476ë => ë 477 478CYRILLIC SMALL LETTER EM: м => ec 479ì => ì 480 481CYRILLIC SMALL LETTER EN: н => ed 482í => í 483 484CYRILLIC SMALL LETTER O: о => ee 485î => î 486 487CYRILLIC SMALL LETTER PE: п => ef 488ï => ï 489 490CYRILLIC SMALL LETTER ER: р => f0 491ð => ð 492 493CYRILLIC SMALL LETTER ES: с => f1 494ñ => ñ 495 496CYRILLIC SMALL LETTER TE: т => f2 497ò => ò 498 499CYRILLIC SMALL LETTER U: у => f3 500ó => ó 501 502CYRILLIC SMALL LETTER EF: ф => f4 503ô => ô 504 505CYRILLIC SMALL LETTER HA: х => f5 506õ => õ 507 508CYRILLIC SMALL LETTER TSE: ц => f6 509ö => ö 510 511CYRILLIC SMALL LETTER CHE: ч => f7 512÷ => ÷ 513 514CYRILLIC SMALL LETTER SHA: ш => f8 515ø => ø 516 517CYRILLIC SMALL LETTER SHCHA: щ => f9 518ù => ù 519 520CYRILLIC SMALL LETTER HARD SIGN: ъ => fa 521ú => ú 522 523CYRILLIC SMALL LETTER YERU: ы => fb 524û => û 525 526CYRILLIC SMALL LETTER SOFT SIGN: ь => fc 527ü => ü 528 529CYRILLIC SMALL LETTER E: э => fd 530ý => ý 531 532CYRILLIC SMALL LETTER YU: ю => fe 533þ => þ 534 535CYRILLIC SMALL LETTER YA: я => ff 536ÿ => ÿ 537