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*** Testing mb_internal_encoding() : usage variations ***
93
94-- Iteration 1 --
95string(%d) "%s"
96bool(true)
97string(5) "UCS-4"
98
99-- Iteration 2 --
100string(5) "UCS-4"
101bool(true)
102string(7) "UCS-4BE"
103
104-- Iteration 3 --
105string(7) "UCS-4BE"
106bool(true)
107string(7) "UCS-4LE"
108
109-- Iteration 4 --
110string(7) "UCS-4LE"
111bool(true)
112string(5) "UCS-2"
113
114-- Iteration 5 --
115string(5) "UCS-2"
116bool(true)
117string(7) "UCS-2BE"
118
119-- Iteration 6 --
120string(7) "UCS-2BE"
121bool(true)
122string(7) "UCS-2LE"
123
124-- Iteration 7 --
125string(7) "UCS-2LE"
126bool(true)
127string(6) "UTF-32"
128
129-- Iteration 8 --
130string(6) "UTF-32"
131bool(true)
132string(8) "UTF-32BE"
133
134-- Iteration 9 --
135string(8) "UTF-32BE"
136bool(true)
137string(8) "UTF-32LE"
138
139-- Iteration 10 --
140string(8) "UTF-32LE"
141bool(true)
142string(6) "UTF-16"
143
144-- Iteration 11 --
145string(6) "UTF-16"
146bool(true)
147string(8) "UTF-16BE"
148
149-- Iteration 12 --
150string(8) "UTF-16BE"
151bool(true)
152string(8) "UTF-16LE"
153
154-- Iteration 13 --
155string(8) "UTF-16LE"
156bool(true)
157string(5) "UTF-7"
158
159-- Iteration 14 --
160string(5) "UTF-7"
161bool(true)
162string(9) "UTF7-IMAP"
163
164-- Iteration 15 --
165string(9) "UTF7-IMAP"
166bool(true)
167string(5) "UTF-8"
168
169-- Iteration 16 --
170string(5) "UTF-8"
171bool(true)
172string(5) "ASCII"
173
174-- Iteration 17 --
175string(5) "ASCII"
176bool(true)
177string(6) "EUC-JP"
178
179-- Iteration 18 --
180string(6) "EUC-JP"
181bool(true)
182string(4) "SJIS"
183
184-- Iteration 19 --
185string(4) "SJIS"
186bool(true)
187string(9) "eucJP-win"
188
189-- Iteration 20 --
190string(9) "eucJP-win"
191bool(true)
192string(8) "SJIS-win"
193
194-- Iteration 21 --
195string(8) "SJIS-win"
196bool(true)
197string(11) "ISO-2022-JP"
198
199-- Iteration 22 --
200string(11) "ISO-2022-JP"
201bool(true)
202string(3) "JIS"
203
204-- Iteration 23 --
205string(3) "JIS"
206bool(true)
207string(10) "ISO-8859-1"
208
209-- Iteration 24 --
210string(10) "ISO-8859-1"
211bool(true)
212string(10) "ISO-8859-2"
213
214-- Iteration 25 --
215string(10) "ISO-8859-2"
216bool(true)
217string(10) "ISO-8859-3"
218
219-- Iteration 26 --
220string(10) "ISO-8859-3"
221bool(true)
222string(10) "ISO-8859-4"
223
224-- Iteration 27 --
225string(10) "ISO-8859-4"
226bool(true)
227string(10) "ISO-8859-5"
228
229-- Iteration 28 --
230string(10) "ISO-8859-5"
231bool(true)
232string(10) "ISO-8859-6"
233
234-- Iteration 29 --
235string(10) "ISO-8859-6"
236bool(true)
237string(10) "ISO-8859-7"
238
239-- Iteration 30 --
240string(10) "ISO-8859-7"
241bool(true)
242string(10) "ISO-8859-8"
243
244-- Iteration 31 --
245string(10) "ISO-8859-8"
246bool(true)
247string(10) "ISO-8859-9"
248
249-- Iteration 32 --
250string(10) "ISO-8859-9"
251bool(true)
252string(11) "ISO-8859-10"
253
254-- Iteration 33 --
255string(11) "ISO-8859-10"
256bool(true)
257string(11) "ISO-8859-13"
258
259-- Iteration 34 --
260string(11) "ISO-8859-13"
261bool(true)
262string(11) "ISO-8859-14"
263
264-- Iteration 35 --
265string(11) "ISO-8859-14"
266bool(true)
267string(11) "ISO-8859-15"
268
269-- Iteration 36 --
270string(11) "ISO-8859-15"
271bool(true)
272string(7) "byte2be"
273
274-- Iteration 37 --
275string(7) "byte2be"
276bool(true)
277string(7) "byte2le"
278
279-- Iteration 38 --
280string(7) "byte2le"
281bool(true)
282string(7) "byte4be"
283
284-- Iteration 39 --
285string(7) "byte4be"
286bool(true)
287string(7) "byte4le"
288
289-- Iteration 40 --
290string(7) "byte4le"
291bool(true)
292string(6) "BASE64"
293
294-- Iteration 41 --
295string(6) "BASE64"
296bool(true)
297string(13) "HTML-ENTITIES"
298
299-- Iteration 42 --
300string(13) "HTML-ENTITIES"
301bool(true)
302string(4) "7bit"
303
304-- Iteration 43 --
305string(4) "7bit"
306bool(true)
307string(4) "8bit"
308
309-- Iteration 44 --
310string(4) "8bit"
311bool(true)
312string(6) "EUC-CN"
313
314-- Iteration 45 --
315string(6) "EUC-CN"
316bool(true)
317string(5) "CP936"
318
319-- Iteration 46 --
320string(5) "CP936"
321bool(true)
322string(2) "HZ"
323
324-- Iteration 47 --
325string(2) "HZ"
326bool(true)
327string(6) "EUC-TW"
328
329-- Iteration 48 --
330string(6) "EUC-TW"
331bool(true)
332string(5) "CP950"
333
334-- Iteration 49 --
335string(5) "CP950"
336bool(true)
337string(5) "BIG-5"
338
339-- Iteration 50 --
340string(5) "BIG-5"
341bool(true)
342string(6) "EUC-KR"
343
344-- Iteration 51 --
345string(6) "EUC-KR"
346bool(true)
347string(3) "UHC"
348
349-- Iteration 52 --
350string(3) "UHC"
351bool(true)
352string(11) "ISO-2022-KR"
353
354-- Iteration 53 --
355string(11) "ISO-2022-KR"
356bool(true)
357string(12) "Windows-1251"
358
359-- Iteration 54 --
360string(12) "Windows-1251"
361bool(true)
362string(12) "Windows-1252"
363
364-- Iteration 55 --
365string(12) "Windows-1252"
366bool(true)
367string(5) "CP866"
368
369-- Iteration 56 --
370string(5) "CP866"
371bool(true)
372string(6) "KOI8-R"
373Done
374