File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
strings /
html_entity_decode_win1251.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue May 29 12:34:45 2012 UTC (12 years, 2 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
HEAD
php 5.4.3+patches
--TEST--
Translation of HTML entities for encoding WIN-1251
--FILE--
<?php
$arr = array(
0x0402 => array(0x80, "CYRILLIC CAPITAL LETTER DJE"),
0x0403 => array(0x81, "CYRILLIC CAPITAL LETTER GJE"),
0x201A => array(0x82, "SINGLE LOW-9 QUOTATION MARK"),
0x0453 => array(0x83, "CYRILLIC SMALL LETTER GJE"),
0x201E => array(0x84, "DOUBLE LOW-9 QUOTATION MARK"),
0x2026 => array(0x85, "HORIZONTAL ELLIPSIS"),
0x2020 => array(0x86, "DAGGER"),
0x2021 => array(0x87, "DOUBLE DAGGER"),
0x20AC => array(0x88, "EURO SIGN"),
0x2030 => array(0x89, "PER MILLE SIGN"),
0x0409 => array(0x8A, "CYRILLIC CAPITAL LETTER LJE"),
0x2039 => array(0x8B, "SINGLE LEFT-POINTING ANGLE QUOTATION MARK"),
0x040A => array(0x8C, "CYRILLIC CAPITAL LETTER NJE"),
0x040C => array(0x8D, "CYRILLIC CAPITAL LETTER KJE"),
0x040B => array(0x8E, "CYRILLIC CAPITAL LETTER TSHE"),
0x040F => array(0x8F, "CYRILLIC CAPITAL LETTER DZHE"),
0x0452 => array(0x90, "CYRILLIC SMALL LETTER DJE"),
0x2018 => array(0x91, "LEFT SINGLE QUOTATION MARK"),
0x2019 => array(0x92, "RIGHT SINGLE QUOTATION MARK"),
0x201C => array(0x93, "LEFT DOUBLE QUOTATION MARK"),
0x201D => array(0x94, "RIGHT DOUBLE QUOTATION MARK"),
0x2022 => array(0x95, "BULLET"),
0x2013 => array(0x96, "EN DASH"),
0x2014 => array(0x97, "EM DASH"),
//0x98 #UNDEFINED
0x2122 => array(0x99, "TRADE MARK SIGN"),
0x0459 => array(0x9A, "CYRILLIC SMALL LETTER LJE"),
0x203A => array(0x9B, "SINGLE RIGHT-POINTING ANGLE QUOTATION MARK"),
0x045A => array(0x9C, "CYRILLIC SMALL LETTER NJE"),
0x045C => array(0x9D, "CYRILLIC SMALL LETTER KJE"),
0x045B => array(0x9E, "CYRILLIC SMALL LETTER TSHE"),
0x045F => array(0x9F, "CYRILLIC SMALL LETTER DZHE"),
0x00A0 => array(0xA0, "NO-BREAK SPACE"),
0x040E => array(0xA1, "CYRILLIC CAPITAL LETTER SHORT U"),
0x045E => array(0xA2, "CYRILLIC SMALL LETTER SHORT U"),
0x0408 => array(0xA3, "CYRILLIC CAPITAL LETTER JE"),
0x00A4 => array(0xA4, "CURRENCY SIGN"),
0x0490 => array(0xA5, "CYRILLIC CAPITAL LETTER GHE WITH UPTURN"),
0x00A6 => array(0xA6, "BROKEN BAR"),
0x00A7 => array(0xA7, "SECTION SIGN"),
0x0401 => array(0xA8, "CYRILLIC CAPITAL LETTER IO"),
0x00A9 => array(0xA9, "COPYRIGHT SIGN"),
0x0404 => array(0xAA, "CYRILLIC CAPITAL LETTER UKRAINIAN IE"),
0x00AB => array(0xAB, "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK"),
0x00AC => array(0xAC, "NOT SIGN"),
0x00AD => array(0xAD, "SOFT HYPHEN"),
0x00AE => array(0xAE, "REGISTERED SIGN"),
0x0407 => array(0xAF, "CYRILLIC CAPITAL LETTER YI"),
0x00B0 => array(0xB0, "DEGREE SIGN"),
0x00B1 => array(0xB1, "PLUS-MINUS SIGN"),
0x0406 => array(0xB2, "CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I"),
0x0456 => array(0xB3, "CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I"),
0x0491 => array(0xB4, "CYRILLIC SMALL LETTER GHE WITH UPTURN"),
0x00B5 => array(0xB5, "MICRO SIGN"),
0x00B6 => array(0xB6, "PILCROW SIGN"),
0x00B7 => array(0xB7, "MIDDLE DOT"),
0x0451 => array(0xB8, "CYRILLIC SMALL LETTER IO"),
0x2116 => array(0xB9, "NUMERO SIGN"),
0x0454 => array(0xBA, "CYRILLIC SMALL LETTER UKRAINIAN IE"),
0x00BB => array(0xBB, "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK"),
0x0458 => array(0xBC, "CYRILLIC SMALL LETTER JE"),
0x0405 => array(0xBD, "CYRILLIC CAPITAL LETTER DZE"),
0x0455 => array(0xBE, "CYRILLIC SMALL LETTER DZE"),
0x0457 => array(0xBF, "CYRILLIC SMALL LETTER YI"),
0x0410 => array(0xC0, "CYRILLIC CAPITAL LETTER A"),
0x0411 => array(0xC1, "CYRILLIC CAPITAL LETTER BE"),
0x0412 => array(0xC2, "CYRILLIC CAPITAL LETTER VE"),
0x0413 => array(0xC3, "CYRILLIC CAPITAL LETTER GHE"),
0x0414 => array(0xC4, "CYRILLIC CAPITAL LETTER DE"),
0x0415 => array(0xC5, "CYRILLIC CAPITAL LETTER IE"),
0x0416 => array(0xC6, "CYRILLIC CAPITAL LETTER ZHE"),
0x0417 => array(0xC7, "CYRILLIC CAPITAL LETTER ZE"),
0x0418 => array(0xC8, "CYRILLIC CAPITAL LETTER I"),
0x0419 => array(0xC9, "CYRILLIC CAPITAL LETTER SHORT I"),
0x041A => array(0xCA, "CYRILLIC CAPITAL LETTER KA"),
0x041B => array(0xCB, "CYRILLIC CAPITAL LETTER EL"),
0x041C => array(0xCC, "CYRILLIC CAPITAL LETTER EM"),
0x041D => array(0xCD, "CYRILLIC CAPITAL LETTER EN"),
0x041E => array(0xCE, "CYRILLIC CAPITAL LETTER O"),
0x041F => array(0xCF, "CYRILLIC CAPITAL LETTER PE"),
0x0420 => array(0xD0, "CYRILLIC CAPITAL LETTER ER"),
0x0421 => array(0xD1, "CYRILLIC CAPITAL LETTER ES"),
0x0422 => array(0xD2, "CYRILLIC CAPITAL LETTER TE"),
0x0423 => array(0xD3, "CYRILLIC CAPITAL LETTER U"),
0x0424 => array(0xD4, "CYRILLIC CAPITAL LETTER EF"),
0x0425 => array(0xD5, "CYRILLIC CAPITAL LETTER HA"),
0x0426 => array(0xD6, "CYRILLIC CAPITAL LETTER TSE"),
0x0427 => array(0xD7, "CYRILLIC CAPITAL LETTER CHE"),
0x0428 => array(0xD8, "CYRILLIC CAPITAL LETTER SHA"),
0x0429 => array(0xD9, "CYRILLIC CAPITAL LETTER SHCHA"),
0x042A => array(0xDA, "CYRILLIC CAPITAL LETTER HARD SIGN"),
0x042B => array(0xDB, "CYRILLIC CAPITAL LETTER YERU"),
0x042C => array(0xDC, "CYRILLIC CAPITAL LETTER SOFT SIGN"),
0x042D => array(0xDD, "CYRILLIC CAPITAL LETTER E"),
0x042E => array(0xDE, "CYRILLIC CAPITAL LETTER YU"),
0x042F => array(0xDF, "CYRILLIC CAPITAL LETTER YA"),
0x0430 => array(0xE0, "CYRILLIC SMALL LETTER A"),
0x0431 => array(0xE1, "CYRILLIC SMALL LETTER BE"),
0x0432 => array(0xE2, "CYRILLIC SMALL LETTER VE"),
0x0433 => array(0xE3, "CYRILLIC SMALL LETTER GHE"),
0x0434 => array(0xE4, "CYRILLIC SMALL LETTER DE"),
0x0435 => array(0xE5, "CYRILLIC SMALL LETTER IE"),
0x0436 => array(0xE6, "CYRILLIC SMALL LETTER ZHE"),
0x0437 => array(0xE7, "CYRILLIC SMALL LETTER ZE"),
0x0438 => array(0xE8, "CYRILLIC SMALL LETTER I"),
0x0439 => array(0xE9, "CYRILLIC SMALL LETTER SHORT I"),
0x043A => array(0xEA, "CYRILLIC SMALL LETTER KA"),
0x043B => array(0xEB, "CYRILLIC SMALL LETTER EL"),
0x043C => array(0xEC, "CYRILLIC SMALL LETTER EM"),
0x043D => array(0xED, "CYRILLIC SMALL LETTER EN"),
0x043E => array(0xEE, "CYRILLIC SMALL LETTER O"),
0x043F => array(0xEF, "CYRILLIC SMALL LETTER PE"),
0x0440 => array(0xF0, "CYRILLIC SMALL LETTER ER"),
0x0441 => array(0xF1, "CYRILLIC SMALL LETTER ES"),
0x0442 => array(0xF2, "CYRILLIC SMALL LETTER TE"),
0x0443 => array(0xF3, "CYRILLIC SMALL LETTER U"),
0x0444 => array(0xF4, "CYRILLIC SMALL LETTER EF"),
0x0445 => array(0xF5, "CYRILLIC SMALL LETTER HA"),
0x0446 => array(0xF6, "CYRILLIC SMALL LETTER TSE"),
0x0447 => array(0xF7, "CYRILLIC SMALL LETTER CHE"),
0x0448 => array(0xF8, "CYRILLIC SMALL LETTER SHA"),
0x0449 => array(0xF9, "CYRILLIC SMALL LETTER SHCHA"),
0x044A => array(0xFA, "CYRILLIC SMALL LETTER HARD SIGN"),
0x044B => array(0xFB, "CYRILLIC SMALL LETTER YERU"),
0x044C => array(0xFC, "CYRILLIC SMALL LETTER SOFT SIGN"),
0x044D => array(0xFD, "CYRILLIC SMALL LETTER E"),
0x044E => array(0xFE, "CYRILLIC SMALL LETTER YU"),
0x044F => array(0xFF, "CYRILLIC SMALL LETTER YA"),
);
$res = html_entity_decode("˜", ENT_QUOTES, 'WINDOWS-1251');
echo "Special test for ˜ (shouldn't decode):\n";
echo $res,"\n\n";
foreach ($arr as $u => $v) {
$ent = sprintf("&#x%X;", $u);
$res = html_entity_decode($ent, ENT_QUOTES, 'WINDOWS-1251');
$d = unpack("H*", $res);
echo sprintf("%s: %s => %s\n", $v[1], $ent, $d[1]);
$ent = sprintf("&#x%X;", $v[0]);
$res = html_entity_decode($ent, ENT_QUOTES, 'WINDOWS-1251');
if ($res[0] != "&" || $res[1] != "#")
$res = unpack("H*", $res)[1];
echo sprintf("%s => %s\n\n", $ent, $res);
}
--EXPECT--
Special test for ˜ (shouldn't decode):
˜
CYRILLIC CAPITAL LETTER DJE: Ђ => 80
€ => €
CYRILLIC CAPITAL LETTER GJE: Ѓ => 81
 => 
SINGLE LOW-9 QUOTATION MARK: ‚ => 82
‚ => ‚
CYRILLIC SMALL LETTER GJE: ѓ => 83
ƒ => ƒ
DOUBLE LOW-9 QUOTATION MARK: „ => 84
„ => „
HORIZONTAL ELLIPSIS: … => 85
… => …
DAGGER: † => 86
† => †
DOUBLE DAGGER: ‡ => 87
‡ => ‡
EURO SIGN: € => 88
ˆ => ˆ
PER MILLE SIGN: ‰ => 89
‰ => ‰
CYRILLIC CAPITAL LETTER LJE: Љ => 8a
Š => Š
SINGLE LEFT-POINTING ANGLE QUOTATION MARK: ‹ => 8b
‹ => ‹
CYRILLIC CAPITAL LETTER NJE: Њ => 8c
Œ => Œ
CYRILLIC CAPITAL LETTER KJE: Ќ => 8d
 => 
CYRILLIC CAPITAL LETTER TSHE: Ћ => 8e
Ž => Ž
CYRILLIC CAPITAL LETTER DZHE: Џ => 8f
 => 
CYRILLIC SMALL LETTER DJE: ђ => 90
 => 
LEFT SINGLE QUOTATION MARK: ‘ => 91
‘ => ‘
RIGHT SINGLE QUOTATION MARK: ’ => 92
’ => ’
LEFT DOUBLE QUOTATION MARK: “ => 93
“ => “
RIGHT DOUBLE QUOTATION MARK: ” => 94
” => ”
BULLET: • => 95
• => •
EN DASH: – => 96
– => –
EM DASH: — => 97
— => —
TRADE MARK SIGN: ™ => 99
™ => ™
CYRILLIC SMALL LETTER LJE: љ => 9a
š => š
SINGLE RIGHT-POINTING ANGLE QUOTATION MARK: › => 9b
› => ›
CYRILLIC SMALL LETTER NJE: њ => 9c
œ => œ
CYRILLIC SMALL LETTER KJE: ќ => 9d
 => 
CYRILLIC SMALL LETTER TSHE: ћ => 9e
ž => ž
CYRILLIC SMALL LETTER DZHE: џ => 9f
Ÿ => Ÿ
NO-BREAK SPACE:   => a0
  => a0
CYRILLIC CAPITAL LETTER SHORT U: Ў => a1
¡ => ¡
CYRILLIC SMALL LETTER SHORT U: ў => a2
¢ => ¢
CYRILLIC CAPITAL LETTER JE: Ј => a3
£ => £
CURRENCY SIGN: ¤ => a4
¤ => a4
CYRILLIC CAPITAL LETTER GHE WITH UPTURN: Ґ => a5
¥ => ¥
BROKEN BAR: ¦ => a6
¦ => a6
SECTION SIGN: § => a7
§ => a7
CYRILLIC CAPITAL LETTER IO: Ё => a8
¨ => ¨
COPYRIGHT SIGN: © => a9
© => a9
CYRILLIC CAPITAL LETTER UKRAINIAN IE: Є => aa
ª => ª
LEFT-POINTING DOUBLE ANGLE QUOTATION MARK: « => ab
« => ab
NOT SIGN: ¬ => ac
¬ => ac
SOFT HYPHEN: ­ => ad
­ => ad
REGISTERED SIGN: ® => ae
® => ae
CYRILLIC CAPITAL LETTER YI: Ї => af
¯ => ¯
DEGREE SIGN: ° => b0
° => b0
PLUS-MINUS SIGN: ± => b1
± => b1
CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I: І => b2
² => ²
CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I: і => b3
³ => ³
CYRILLIC SMALL LETTER GHE WITH UPTURN: ґ => b4
´ => ´
MICRO SIGN: µ => b5
µ => b5
PILCROW SIGN: ¶ => b6
¶ => b6
MIDDLE DOT: · => b7
· => b7
CYRILLIC SMALL LETTER IO: ё => b8
¸ => ¸
NUMERO SIGN: № => b9
¹ => ¹
CYRILLIC SMALL LETTER UKRAINIAN IE: є => ba
º => º
RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK: » => bb
» => bb
CYRILLIC SMALL LETTER JE: ј => bc
¼ => ¼
CYRILLIC CAPITAL LETTER DZE: Ѕ => bd
½ => ½
CYRILLIC SMALL LETTER DZE: ѕ => be
¾ => ¾
CYRILLIC SMALL LETTER YI: ї => bf
¿ => ¿
CYRILLIC CAPITAL LETTER A: А => c0
À => À
CYRILLIC CAPITAL LETTER BE: Б => c1
Á => Á
CYRILLIC CAPITAL LETTER VE: В => c2
 => Â
CYRILLIC CAPITAL LETTER GHE: Г => c3
à => Ã
CYRILLIC CAPITAL LETTER DE: Д => c4
Ä => Ä
CYRILLIC CAPITAL LETTER IE: Е => c5
Å => Å
CYRILLIC CAPITAL LETTER ZHE: Ж => c6
Æ => Æ
CYRILLIC CAPITAL LETTER ZE: З => c7
Ç => Ç
CYRILLIC CAPITAL LETTER I: И => c8
È => È
CYRILLIC CAPITAL LETTER SHORT I: Й => c9
É => É
CYRILLIC CAPITAL LETTER KA: К => ca
Ê => Ê
CYRILLIC CAPITAL LETTER EL: Л => cb
Ë => Ë
CYRILLIC CAPITAL LETTER EM: М => cc
Ì => Ì
CYRILLIC CAPITAL LETTER EN: Н => cd
Í => Í
CYRILLIC CAPITAL LETTER O: О => ce
Î => Î
CYRILLIC CAPITAL LETTER PE: П => cf
Ï => Ï
CYRILLIC CAPITAL LETTER ER: Р => d0
Ð => Ð
CYRILLIC CAPITAL LETTER ES: С => d1
Ñ => Ñ
CYRILLIC CAPITAL LETTER TE: Т => d2
Ò => Ò
CYRILLIC CAPITAL LETTER U: У => d3
Ó => Ó
CYRILLIC CAPITAL LETTER EF: Ф => d4
Ô => Ô
CYRILLIC CAPITAL LETTER HA: Х => d5
Õ => Õ
CYRILLIC CAPITAL LETTER TSE: Ц => d6
Ö => Ö
CYRILLIC CAPITAL LETTER CHE: Ч => d7
× => ×
CYRILLIC CAPITAL LETTER SHA: Ш => d8
Ø => Ø
CYRILLIC CAPITAL LETTER SHCHA: Щ => d9
Ù => Ù
CYRILLIC CAPITAL LETTER HARD SIGN: Ъ => da
Ú => Ú
CYRILLIC CAPITAL LETTER YERU: Ы => db
Û => Û
CYRILLIC CAPITAL LETTER SOFT SIGN: Ь => dc
Ü => Ü
CYRILLIC CAPITAL LETTER E: Э => dd
Ý => Ý
CYRILLIC CAPITAL LETTER YU: Ю => de
Þ => Þ
CYRILLIC CAPITAL LETTER YA: Я => df
ß => ß
CYRILLIC SMALL LETTER A: а => e0
à => à
CYRILLIC SMALL LETTER BE: б => e1
á => á
CYRILLIC SMALL LETTER VE: в => e2
â => â
CYRILLIC SMALL LETTER GHE: г => e3
ã => ã
CYRILLIC SMALL LETTER DE: д => e4
ä => ä
CYRILLIC SMALL LETTER IE: е => e5
å => å
CYRILLIC SMALL LETTER ZHE: ж => e6
æ => æ
CYRILLIC SMALL LETTER ZE: з => e7
ç => ç
CYRILLIC SMALL LETTER I: и => e8
è => è
CYRILLIC SMALL LETTER SHORT I: й => e9
é => é
CYRILLIC SMALL LETTER KA: к => ea
ê => ê
CYRILLIC SMALL LETTER EL: л => eb
ë => ë
CYRILLIC SMALL LETTER EM: м => ec
ì => ì
CYRILLIC SMALL LETTER EN: н => ed
í => í
CYRILLIC SMALL LETTER O: о => ee
î => î
CYRILLIC SMALL LETTER PE: п => ef
ï => ï
CYRILLIC SMALL LETTER ER: р => f0
ð => ð
CYRILLIC SMALL LETTER ES: с => f1
ñ => ñ
CYRILLIC SMALL LETTER TE: т => f2
ò => ò
CYRILLIC SMALL LETTER U: у => f3
ó => ó
CYRILLIC SMALL LETTER EF: ф => f4
ô => ô
CYRILLIC SMALL LETTER HA: х => f5
õ => õ
CYRILLIC SMALL LETTER TSE: ц => f6
ö => ö
CYRILLIC SMALL LETTER CHE: ч => f7
÷ => ÷
CYRILLIC SMALL LETTER SHA: ш => f8
ø => ø
CYRILLIC SMALL LETTER SHCHA: щ => f9
ù => ù
CYRILLIC SMALL LETTER HARD SIGN: ъ => fa
ú => ú
CYRILLIC SMALL LETTER YERU: ы => fb
û => û
CYRILLIC SMALL LETTER SOFT SIGN: ь => fc
ü => ü
CYRILLIC SMALL LETTER E: э => fd
ý => ý
CYRILLIC SMALL LETTER YU: ю => fe
þ => þ
CYRILLIC SMALL LETTER YA: я => ff
ÿ => ÿ
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>