1--TEST--
2htmlentities() conformance check (HTML 4)
3--FILE--
4<?php
5function utf32_utf8($k) {
6	if ($k < 0x80) {
7		$retval = pack('C', $k);
8	} else if ($k < 0x800) {
9		$retval = pack('C2',
10            0xc0 | ($k >> 6),
11            0x80 | ($k & 0x3f));
12	} else if ($k < 0x10000) {
13        $retval = pack('C3',
14            0xe0 | ($k >> 12),
15            0x80 | (($k >> 6) & 0x3f),
16            0x80 | ($k & 0x3f));
17	} else if ($k < 0x200000) {
18        $retval = pack('C4',
19            0xf0 | ($k >> 18),
20            0x80 | (($k >> 12) & 0x3f),
21            0x80 | (($k >> 6) & 0x3f),
22            0x80 | ($k & 0x3f));
23	} else if ($k < 0x4000000) {
24        $retval = pack('C5',
25            0xf8 | ($k >> 24),
26            0x80 | (($k >> 18) & 0x3f),
27            0x80 | (($k >> 12) & 0x3f),
28            0x80 | (($k >> 6) & 0x3f),
29            0x80 | ($k & 0x3f));
30	} else {
31        $retval = pack('C6',
32            0xfc | ($k >> 30),
33            0x80 | (($k >> 24) & 0x3f),
34            0x80 | (($k >> 18) & 0x3f),
35            0x80 | (($k >> 12) & 0x3f),
36            0x80 | (($k >> 6) & 0x3f),
37            0x80 | ($k & 0x3f));
38	}
39	return $retval;
40}
41
42$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, 'UTF-8');
43
44for ($i = 0; $i < 0x2710; $i++) {
45    if ($i >= 0xd800 && $i < 0xe000)
46        continue;
47    $str = utf32_utf8($i);
48	if (isset($table[$str])) {
49		printf("%s\tU+%05X\n", $table[$str], $i);
50		unset($table[$str]);
51	}
52}
53
54if (!empty($table)) {
55	echo "Not matched entities: ";
56	var_dump($table);
57}
58
59?>
60--EXPECT--
61&quot;	U+00022
62&amp;	U+00026
63&#039;	U+00027
64&lt;	U+0003C
65&gt;	U+0003E
66&nbsp;	U+000A0
67&iexcl;	U+000A1
68&cent;	U+000A2
69&pound;	U+000A3
70&curren;	U+000A4
71&yen;	U+000A5
72&brvbar;	U+000A6
73&sect;	U+000A7
74&uml;	U+000A8
75&copy;	U+000A9
76&ordf;	U+000AA
77&laquo;	U+000AB
78&not;	U+000AC
79&shy;	U+000AD
80&reg;	U+000AE
81&macr;	U+000AF
82&deg;	U+000B0
83&plusmn;	U+000B1
84&sup2;	U+000B2
85&sup3;	U+000B3
86&acute;	U+000B4
87&micro;	U+000B5
88&para;	U+000B6
89&middot;	U+000B7
90&cedil;	U+000B8
91&sup1;	U+000B9
92&ordm;	U+000BA
93&raquo;	U+000BB
94&frac14;	U+000BC
95&frac12;	U+000BD
96&frac34;	U+000BE
97&iquest;	U+000BF
98&Agrave;	U+000C0
99&Aacute;	U+000C1
100&Acirc;	U+000C2
101&Atilde;	U+000C3
102&Auml;	U+000C4
103&Aring;	U+000C5
104&AElig;	U+000C6
105&Ccedil;	U+000C7
106&Egrave;	U+000C8
107&Eacute;	U+000C9
108&Ecirc;	U+000CA
109&Euml;	U+000CB
110&Igrave;	U+000CC
111&Iacute;	U+000CD
112&Icirc;	U+000CE
113&Iuml;	U+000CF
114&ETH;	U+000D0
115&Ntilde;	U+000D1
116&Ograve;	U+000D2
117&Oacute;	U+000D3
118&Ocirc;	U+000D4
119&Otilde;	U+000D5
120&Ouml;	U+000D6
121&times;	U+000D7
122&Oslash;	U+000D8
123&Ugrave;	U+000D9
124&Uacute;	U+000DA
125&Ucirc;	U+000DB
126&Uuml;	U+000DC
127&Yacute;	U+000DD
128&THORN;	U+000DE
129&szlig;	U+000DF
130&agrave;	U+000E0
131&aacute;	U+000E1
132&acirc;	U+000E2
133&atilde;	U+000E3
134&auml;	U+000E4
135&aring;	U+000E5
136&aelig;	U+000E6
137&ccedil;	U+000E7
138&egrave;	U+000E8
139&eacute;	U+000E9
140&ecirc;	U+000EA
141&euml;	U+000EB
142&igrave;	U+000EC
143&iacute;	U+000ED
144&icirc;	U+000EE
145&iuml;	U+000EF
146&eth;	U+000F0
147&ntilde;	U+000F1
148&ograve;	U+000F2
149&oacute;	U+000F3
150&ocirc;	U+000F4
151&otilde;	U+000F5
152&ouml;	U+000F6
153&divide;	U+000F7
154&oslash;	U+000F8
155&ugrave;	U+000F9
156&uacute;	U+000FA
157&ucirc;	U+000FB
158&uuml;	U+000FC
159&yacute;	U+000FD
160&thorn;	U+000FE
161&yuml;	U+000FF
162&OElig;	U+00152
163&oelig;	U+00153
164&Scaron;	U+00160
165&scaron;	U+00161
166&Yuml;	U+00178
167&fnof;	U+00192
168&circ;	U+002C6
169&tilde;	U+002DC
170&Alpha;	U+00391
171&Beta;	U+00392
172&Gamma;	U+00393
173&Delta;	U+00394
174&Epsilon;	U+00395
175&Zeta;	U+00396
176&Eta;	U+00397
177&Theta;	U+00398
178&Iota;	U+00399
179&Kappa;	U+0039A
180&Lambda;	U+0039B
181&Mu;	U+0039C
182&Nu;	U+0039D
183&Xi;	U+0039E
184&Omicron;	U+0039F
185&Pi;	U+003A0
186&Rho;	U+003A1
187&Sigma;	U+003A3
188&Tau;	U+003A4
189&Upsilon;	U+003A5
190&Phi;	U+003A6
191&Chi;	U+003A7
192&Psi;	U+003A8
193&Omega;	U+003A9
194&alpha;	U+003B1
195&beta;	U+003B2
196&gamma;	U+003B3
197&delta;	U+003B4
198&epsilon;	U+003B5
199&zeta;	U+003B6
200&eta;	U+003B7
201&theta;	U+003B8
202&iota;	U+003B9
203&kappa;	U+003BA
204&lambda;	U+003BB
205&mu;	U+003BC
206&nu;	U+003BD
207&xi;	U+003BE
208&omicron;	U+003BF
209&pi;	U+003C0
210&rho;	U+003C1
211&sigmaf;	U+003C2
212&sigma;	U+003C3
213&tau;	U+003C4
214&upsilon;	U+003C5
215&phi;	U+003C6
216&chi;	U+003C7
217&psi;	U+003C8
218&omega;	U+003C9
219&thetasym;	U+003D1
220&upsih;	U+003D2
221&piv;	U+003D6
222&ensp;	U+02002
223&emsp;	U+02003
224&thinsp;	U+02009
225&zwnj;	U+0200C
226&zwj;	U+0200D
227&lrm;	U+0200E
228&rlm;	U+0200F
229&ndash;	U+02013
230&mdash;	U+02014
231&lsquo;	U+02018
232&rsquo;	U+02019
233&sbquo;	U+0201A
234&ldquo;	U+0201C
235&rdquo;	U+0201D
236&bdquo;	U+0201E
237&dagger;	U+02020
238&Dagger;	U+02021
239&bull;	U+02022
240&hellip;	U+02026
241&permil;	U+02030
242&prime;	U+02032
243&Prime;	U+02033
244&lsaquo;	U+02039
245&rsaquo;	U+0203A
246&oline;	U+0203E
247&frasl;	U+02044
248&euro;	U+020AC
249&image;	U+02111
250&weierp;	U+02118
251&real;	U+0211C
252&trade;	U+02122
253&alefsym;	U+02135
254&larr;	U+02190
255&uarr;	U+02191
256&rarr;	U+02192
257&darr;	U+02193
258&harr;	U+02194
259&crarr;	U+021B5
260&lArr;	U+021D0
261&uArr;	U+021D1
262&rArr;	U+021D2
263&dArr;	U+021D3
264&hArr;	U+021D4
265&forall;	U+02200
266&part;	U+02202
267&exist;	U+02203
268&empty;	U+02205
269&nabla;	U+02207
270&isin;	U+02208
271&notin;	U+02209
272&ni;	U+0220B
273&prod;	U+0220F
274&sum;	U+02211
275&minus;	U+02212
276&lowast;	U+02217
277&radic;	U+0221A
278&prop;	U+0221D
279&infin;	U+0221E
280&ang;	U+02220
281&and;	U+02227
282&or;	U+02228
283&cap;	U+02229
284&cup;	U+0222A
285&int;	U+0222B
286&there4;	U+02234
287&sim;	U+0223C
288&cong;	U+02245
289&asymp;	U+02248
290&ne;	U+02260
291&equiv;	U+02261
292&le;	U+02264
293&ge;	U+02265
294&sub;	U+02282
295&sup;	U+02283
296&nsub;	U+02284
297&sube;	U+02286
298&supe;	U+02287
299&oplus;	U+02295
300&otimes;	U+02297
301&perp;	U+022A5
302&sdot;	U+022C5
303&lceil;	U+02308
304&rceil;	U+02309
305&lfloor;	U+0230A
306&rfloor;	U+0230B
307&lang;	U+02329
308&rang;	U+0232A
309&loz;	U+025CA
310&spades;	U+02660
311&clubs;	U+02663
312&hearts;	U+02665
313&diams;	U+02666
314