1--TEST--
2htmlentities() / htmlspecialchars() ENT_SUBSTITUTE
3--FILE--
4<?php
5$tests = array(
6    "\x41\xC2\x3E\x42", // Unicode TR #36, 3.1.1; do not consume valid successor bytes
7    "\xE3\x80\x22",    // Unicode TR #36, 3.6.1; use strategy #2
8    "\x41\x98\xBA\x42\xE2\x98\x43\xE2\x98\xBA\xE2\x98", // example from HTML5, section 2.4
9);
10
11foreach ($tests as $test) {
12    $a = htmlentities($test, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");
13    var_dump($a, bin2hex($a));
14    $a = htmlspecialchars($test, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");
15    var_dump($a, bin2hex($a));
16}
17?>
18--EXPECT--
19string(9) "A�&gt;B"
20string(18) "41efbfbd2667743b42"
21string(9) "A�&gt;B"
22string(18) "41efbfbd2667743b42"
23string(9) "�&quot;"
24string(18) "efbfbd2671756f743b"
25string(9) "�&quot;"
26string(18) "efbfbd2671756f743b"
27string(18) "A��B�C☺�"
28string(36) "41efbfbdefbfbd42efbfbd43e298baefbfbd"
29string(18) "A��B�C☺�"
30string(36) "41efbfbdefbfbd42efbfbd43e298baefbfbd"
31