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