1--TEST--
2Test mb_internal_encoding() function : usage variations - Test different encodings
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7/*
8 * Test all listed encoding types from php.net to check all are known to function
9 * NB: The strings passed are *NOT* necessarily encoded in the encoding passed to the function.
10 * This test is purely to see whether the function recognises the encoding.
11 */
12
13echo "*** Testing mb_internal_encoding() : usage variations ***\n";
14
15$encoding = array('UCS-4',			/*1*/
16                  'UCS-4BE',
17                  'UCS-4LE',
18                  'UCS-2',
19                  'UCS-2BE',		/*5*/
20                  'UCS-2LE',
21                  'UTF-32',
22                  'UTF-32BE',
23                  'UTF-32LE',
24                  'UTF-16',			/*10*/
25                  'UTF-16BE',
26                  'UTF-16LE',
27                  'UTF-7',
28                  'UTF7-IMAP',
29                  'UTF-8',			/*15*/
30                  'ASCII',
31                  'EUC-JP',
32                  'SJIS',
33                  'eucJP-win',
34                  'SJIS-win',		/*20*/
35                  'ISO-2022-JP',
36                  'JIS',
37                  'ISO-8859-1',
38                  'ISO-8859-2',
39                  'ISO-8859-3',		/*25*/
40                  'ISO-8859-4',
41                  'ISO-8859-5',
42                  'ISO-8859-6',
43                  'ISO-8859-7',
44                  'ISO-8859-8',		/*30*/
45                  'ISO-8859-9',
46                  'ISO-8859-10',
47                  'ISO-8859-13',
48                  'ISO-8859-14',
49                  'ISO-8859-15',	/*35*/
50                  'BASE64',			/*40*/
51                  'HTML-ENTITIES',
52                  '7bit',
53                  '8bit',
54                  'EUC-CN',
55                  'CP936',			/*45*/
56                  'HZ',
57                  'EUC-TW',
58                  'CP950',
59                  'BIG-5',
60                  'EUC-KR',			/*50*/
61                  'UHC',
62                  'ISO-2022-KR',
63                  'Windows-1251',
64                  'Windows-1252',
65                  'CP866',			/*55*/
66                  'KOI8-R');		/*56*/
67
68$iterator = 1;
69foreach($encoding as $enc) {
70    echo "\n-- Iteration $iterator --\n";
71    var_dump(mb_internal_encoding());
72    var_dump(mb_internal_encoding($enc));
73    var_dump(mb_internal_encoding());
74    $iterator++;
75}
76echo "Done";
77?>
78--EXPECTF--
79*** Testing mb_internal_encoding() : usage variations ***
80
81-- Iteration 1 --
82string(%d) "%s"
83bool(true)
84string(5) "UCS-4"
85
86-- Iteration 2 --
87string(5) "UCS-4"
88bool(true)
89string(7) "UCS-4BE"
90
91-- Iteration 3 --
92string(7) "UCS-4BE"
93bool(true)
94string(7) "UCS-4LE"
95
96-- Iteration 4 --
97string(7) "UCS-4LE"
98bool(true)
99string(5) "UCS-2"
100
101-- Iteration 5 --
102string(5) "UCS-2"
103bool(true)
104string(7) "UCS-2BE"
105
106-- Iteration 6 --
107string(7) "UCS-2BE"
108bool(true)
109string(7) "UCS-2LE"
110
111-- Iteration 7 --
112string(7) "UCS-2LE"
113bool(true)
114string(6) "UTF-32"
115
116-- Iteration 8 --
117string(6) "UTF-32"
118bool(true)
119string(8) "UTF-32BE"
120
121-- Iteration 9 --
122string(8) "UTF-32BE"
123bool(true)
124string(8) "UTF-32LE"
125
126-- Iteration 10 --
127string(8) "UTF-32LE"
128bool(true)
129string(6) "UTF-16"
130
131-- Iteration 11 --
132string(6) "UTF-16"
133bool(true)
134string(8) "UTF-16BE"
135
136-- Iteration 12 --
137string(8) "UTF-16BE"
138bool(true)
139string(8) "UTF-16LE"
140
141-- Iteration 13 --
142string(8) "UTF-16LE"
143bool(true)
144string(5) "UTF-7"
145
146-- Iteration 14 --
147string(5) "UTF-7"
148bool(true)
149string(9) "UTF7-IMAP"
150
151-- Iteration 15 --
152string(9) "UTF7-IMAP"
153bool(true)
154string(5) "UTF-8"
155
156-- Iteration 16 --
157string(5) "UTF-8"
158bool(true)
159string(5) "ASCII"
160
161-- Iteration 17 --
162string(5) "ASCII"
163bool(true)
164string(6) "EUC-JP"
165
166-- Iteration 18 --
167string(6) "EUC-JP"
168bool(true)
169string(4) "SJIS"
170
171-- Iteration 19 --
172string(4) "SJIS"
173bool(true)
174string(9) "eucJP-win"
175
176-- Iteration 20 --
177string(9) "eucJP-win"
178bool(true)
179string(8) "SJIS-win"
180
181-- Iteration 21 --
182string(8) "SJIS-win"
183bool(true)
184string(11) "ISO-2022-JP"
185
186-- Iteration 22 --
187string(11) "ISO-2022-JP"
188bool(true)
189string(3) "JIS"
190
191-- Iteration 23 --
192string(3) "JIS"
193bool(true)
194string(10) "ISO-8859-1"
195
196-- Iteration 24 --
197string(10) "ISO-8859-1"
198bool(true)
199string(10) "ISO-8859-2"
200
201-- Iteration 25 --
202string(10) "ISO-8859-2"
203bool(true)
204string(10) "ISO-8859-3"
205
206-- Iteration 26 --
207string(10) "ISO-8859-3"
208bool(true)
209string(10) "ISO-8859-4"
210
211-- Iteration 27 --
212string(10) "ISO-8859-4"
213bool(true)
214string(10) "ISO-8859-5"
215
216-- Iteration 28 --
217string(10) "ISO-8859-5"
218bool(true)
219string(10) "ISO-8859-6"
220
221-- Iteration 29 --
222string(10) "ISO-8859-6"
223bool(true)
224string(10) "ISO-8859-7"
225
226-- Iteration 30 --
227string(10) "ISO-8859-7"
228bool(true)
229string(10) "ISO-8859-8"
230
231-- Iteration 31 --
232string(10) "ISO-8859-8"
233bool(true)
234string(10) "ISO-8859-9"
235
236-- Iteration 32 --
237string(10) "ISO-8859-9"
238bool(true)
239string(11) "ISO-8859-10"
240
241-- Iteration 33 --
242string(11) "ISO-8859-10"
243bool(true)
244string(11) "ISO-8859-13"
245
246-- Iteration 34 --
247string(11) "ISO-8859-13"
248bool(true)
249string(11) "ISO-8859-14"
250
251-- Iteration 35 --
252string(11) "ISO-8859-14"
253bool(true)
254string(11) "ISO-8859-15"
255
256-- Iteration 36 --
257string(11) "ISO-8859-15"
258bool(true)
259string(6) "BASE64"
260
261-- Iteration 37 --
262string(6) "BASE64"
263bool(true)
264string(13) "HTML-ENTITIES"
265
266-- Iteration 38 --
267string(13) "HTML-ENTITIES"
268bool(true)
269string(4) "7bit"
270
271-- Iteration 39 --
272string(4) "7bit"
273bool(true)
274string(4) "8bit"
275
276-- Iteration 40 --
277string(4) "8bit"
278bool(true)
279string(6) "EUC-CN"
280
281-- Iteration 41 --
282string(6) "EUC-CN"
283bool(true)
284string(5) "CP936"
285
286-- Iteration 42 --
287string(5) "CP936"
288bool(true)
289string(2) "HZ"
290
291-- Iteration 43 --
292string(2) "HZ"
293bool(true)
294string(6) "EUC-TW"
295
296-- Iteration 44 --
297string(6) "EUC-TW"
298bool(true)
299string(5) "CP950"
300
301-- Iteration 45 --
302string(5) "CP950"
303bool(true)
304string(5) "BIG-5"
305
306-- Iteration 46 --
307string(5) "BIG-5"
308bool(true)
309string(6) "EUC-KR"
310
311-- Iteration 47 --
312string(6) "EUC-KR"
313bool(true)
314string(3) "UHC"
315
316-- Iteration 48 --
317string(3) "UHC"
318bool(true)
319string(11) "ISO-2022-KR"
320
321-- Iteration 49 --
322string(11) "ISO-2022-KR"
323bool(true)
324string(12) "Windows-1251"
325
326-- Iteration 50 --
327string(12) "Windows-1251"
328bool(true)
329string(12) "Windows-1252"
330
331-- Iteration 51 --
332string(12) "Windows-1252"
333bool(true)
334string(5) "CP866"
335
336-- Iteration 52 --
337string(5) "CP866"
338bool(true)
339string(6) "KOI8-R"
340Done
341