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