1--TEST--
2htmlentities() / htmlspecialchars() ENT_SUBSTITUTE EUC-JP
3--FILE--
4<?php
5$tests = array(
6    "\x8F\xA1\xFF", //2 sub as 2nd is potentially valid as lead
7    "\x8F\xA1", //2 sub, as 2nd is potentially valid as lead
8    "\x8F", //1 sub
9    "\x8F\xA0", //1 sub, A0 is not valid as sole/first byte
10    "\x8F\xA1\x21", //2 sub, no consume last
11    "\x8F\x21", //1 sub, no consume last
12    "\x8E\xAE", //valid
13    "\x8E", //1 sub
14    "\x8E\x21", //1 sub, no consume last
15    "\xB2\xFF", //1 sub
16    "\xB2", //1 sub
17    "\xB2\x21", //1 sub, no consume last
18    "\xA0", //1 sub
19);
20
21foreach ($tests as $test) {
22    error_reporting(~E_STRICT);
23    $a = htmlentities($test, ENT_QUOTES | ENT_SUBSTITUTE, "EUC-JP");
24    error_reporting(-1);
25	var_dump($a, bin2hex($a));
26    $a = htmlspecialchars($test, ENT_QUOTES | ENT_SUBSTITUTE, "EUC-JP");
27	var_dump($a, bin2hex($a));
28    echo "\n";
29}
30?>
31--EXPECT--
32string(16) "&#xFFFD;&#xFFFD;"
33string(32) "262378464646443b262378464646443b"
34string(16) "&#xFFFD;&#xFFFD;"
35string(32) "262378464646443b262378464646443b"
36
37string(16) "&#xFFFD;&#xFFFD;"
38string(32) "262378464646443b262378464646443b"
39string(16) "&#xFFFD;&#xFFFD;"
40string(32) "262378464646443b262378464646443b"
41
42string(8) "&#xFFFD;"
43string(16) "262378464646443b"
44string(8) "&#xFFFD;"
45string(16) "262378464646443b"
46
47string(8) "&#xFFFD;"
48string(16) "262378464646443b"
49string(8) "&#xFFFD;"
50string(16) "262378464646443b"
51
52string(17) "&#xFFFD;&#xFFFD;!"
53string(34) "262378464646443b262378464646443b21"
54string(17) "&#xFFFD;&#xFFFD;!"
55string(34) "262378464646443b262378464646443b21"
56
57string(9) "&#xFFFD;!"
58string(18) "262378464646443b21"
59string(9) "&#xFFFD;!"
60string(18) "262378464646443b21"
61
62string(2) "��"
63string(4) "8eae"
64string(2) "��"
65string(4) "8eae"
66
67string(8) "&#xFFFD;"
68string(16) "262378464646443b"
69string(8) "&#xFFFD;"
70string(16) "262378464646443b"
71
72string(9) "&#xFFFD;!"
73string(18) "262378464646443b21"
74string(9) "&#xFFFD;!"
75string(18) "262378464646443b21"
76
77string(8) "&#xFFFD;"
78string(16) "262378464646443b"
79string(8) "&#xFFFD;"
80string(16) "262378464646443b"
81
82string(8) "&#xFFFD;"
83string(16) "262378464646443b"
84string(8) "&#xFFFD;"
85string(16) "262378464646443b"
86
87string(9) "&#xFFFD;!"
88string(18) "262378464646443b21"
89string(9) "&#xFFFD;!"
90string(18) "262378464646443b21"
91
92string(8) "&#xFFFD;"
93string(16) "262378464646443b"
94string(8) "&#xFFFD;"
95string(16) "262378464646443b"
96