1--TEST--
2default_charset and htmlentities/htmlspecialchars/html_entity_decode
3--INI--
4default_charset=UTF-8
5internal_encoding=
6input_encoding=
7output_encoding=
8--FILE--
9<?php
10echo "*** Default php.ini value ***\n";
11var_dump(ini_get('default_charset'),
12		 ini_get('internal_encoding'),
13		 ini_get('input_encoding'),
14		 ini_get('output_encoding')
15	);
16
17
18echo "*** Runtime change of default_charset ***\n";
19var_dump(ini_set('default_charset', 'cp1252'));
20
21echo "*** Test with updated default_charset ***\n";
22var_dump(ini_get('default_charset'),
23		 ini_get('internal_encoding'),
24		 ini_get('input_encoding'),
25		 ini_get('output_encoding')
26	);
27
28var_dump(htmlentities("\xA3", ENT_HTML5));
29var_dump(htmlentities("\xA3", ENT_HTML5, 'cp1252'));
30
31var_dump(bin2hex(html_entity_decode("&pound;", ENT_HTML5)));
32var_dump(bin2hex(html_entity_decode("&pound;", ENT_HTML5, 'cp1252')));
33
34// Set internal_encoding to empty and try again
35echo "*** Change internal_encoding to empty ***\n";
36var_dump(ini_set('internal_encoding', ''));
37var_dump(ini_get('default_charset'),
38		 ini_get('internal_encoding'),
39		 ini_get('input_encoding'),
40		 ini_get('output_encoding')
41	);
42
43var_dump(htmlentities("\xA3", ENT_HTML5));
44var_dump(htmlentities("\xA3", ENT_HTML5, 'cp1252'));
45var_dump(bin2hex(html_entity_decode("&pound;", ENT_HTML5)));
46var_dump(bin2hex(html_entity_decode("&pound;", ENT_HTML5, 'cp1252')));
47
48echo "*** Update input/output_encoding ***\n";
49var_dump(ini_set('input_encoding', 'ISO-8859-1'));
50var_dump(ini_set('output_encoding', 'ISO-8859-1'));
51var_dump(ini_get('default_charset'),
52		 ini_get('internal_encoding'),
53		 ini_get('input_encoding'),
54		 ini_get('output_encoding')
55	);
56
57// Should not be affected
58var_dump(htmlentities("\xA3", ENT_HTML5));
59var_dump(htmlentities("\xA3", ENT_HTML5, 'cp1252'));
60var_dump(bin2hex(html_entity_decode("&pound;", ENT_HTML5)));
61var_dump(bin2hex(html_entity_decode("&pound;", ENT_HTML5, 'cp1252')));
62
63echo "Done\n";
64
65?>
66--EXPECT--
67*** Default php.ini value ***
68string(5) "UTF-8"
69string(0) ""
70string(0) ""
71string(0) ""
72*** Runtime change of default_charset ***
73string(5) "UTF-8"
74*** Test with updated default_charset ***
75string(6) "cp1252"
76string(0) ""
77string(0) ""
78string(0) ""
79string(7) "&pound;"
80string(7) "&pound;"
81string(2) "a3"
82string(2) "a3"
83*** Change internal_encoding to empty ***
84string(0) ""
85string(6) "cp1252"
86string(0) ""
87string(0) ""
88string(0) ""
89string(7) "&pound;"
90string(7) "&pound;"
91string(2) "a3"
92string(2) "a3"
93*** Update input/output_encoding ***
94string(0) ""
95string(0) ""
96string(6) "cp1252"
97string(0) ""
98string(10) "ISO-8859-1"
99string(10) "ISO-8859-1"
100string(7) "&pound;"
101string(7) "&pound;"
102string(2) "a3"
103string(2) "a3"
104Done
105