1--TEST--
2Test mb_convert_encoding() function : array functionality
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7/*
8 * Test basic functionality of mb_convert_encoding()
9 */
10
11echo "*** Testing mb_convert_encoding() : array functionality ***\n";
12
13//All strings are the same when displayed in their respective encodings
14$sjis_string[] = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
15$sjis_string[] = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
16$jis_string[] = base64_decode('GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==');
17$jis_string[] = base64_decode('GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==');
18$euc_jp_string[] = base64_decode('xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==');
19$euc_jp_string[] = base64_decode('xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow==');
20$utf8_string[] = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
21$utf8_string[] = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
22
23
24function base64_encode_array($input) {
25    foreach ($input as $var) {
26        $ret[] = base64_encode($var);
27    }
28    return $ret;
29}
30
31echo "\n-- Convert to JIS --\n";
32echo "JIS encoded string in base64:\n";
33var_dump(base64_encode_array($jis_string));
34echo "Converted Strings:\n";
35var_dump(base64_encode_array(mb_convert_encoding($sjis_string, 'JIS', 'SJIS')));
36var_dump(base64_encode_array(mb_convert_encoding($euc_jp_string, 'JIS', 'EUC-JP')));
37var_dump(base64_encode_array(mb_convert_encoding($utf8_string, 'JIS', 'UTF-8')));
38
39echo "\n-- Convert to EUC-JP --\n";
40echo "EUC-JP encoded string in base64:\n";
41var_dump(base64_encode_array($euc_jp_string));
42echo "Converted Strings:\n";
43var_dump(base64_encode_array(mb_convert_encoding($sjis_string, 'EUC-JP', 'SJIS')));
44var_dump(base64_encode_array(mb_convert_encoding($jis_string, 'EUC-JP', 'JIS')));
45var_dump(base64_encode_array(mb_convert_encoding($utf8_string, 'EUC-JP', 'UTF-8')));
46
47echo "\n-- Convert to SJIS --\n";
48echo "SJIS encoded string in base64:\n";
49var_dump(base64_encode_array($sjis_string));
50echo "Converted Strings:\n";
51var_dump(base64_encode_array(mb_convert_encoding($jis_string, 'SJIS', 'JIS')));
52var_dump(base64_encode_array(mb_convert_encoding($euc_jp_string, 'SJIS', 'EUC-JP')));
53var_dump(base64_encode_array(mb_convert_encoding($utf8_string, 'SJIS', 'UTF-8')));
54
55echo "\n-- Convert to UTF-8 --\n";
56echo "UTF-8 encoded string in base64:\n";
57var_dump(base64_encode_array($utf8_string));
58echo "Converted Strings:\n";
59var_dump(base64_encode_array(mb_convert_encoding($sjis_string, 'UTF-8', 'SJIS')));
60var_dump(base64_encode_array(mb_convert_encoding($jis_string, 'UTF-8', 'JIS')));
61var_dump(base64_encode_array(mb_convert_encoding($euc_jp_string, 'UTF-8', 'EUC-JP')));
62
63echo "Done";
64?>
65--EXPECT--
66*** Testing mb_convert_encoding() : array functionality ***
67
68-- Convert to JIS --
69JIS encoded string in base64:
70array(2) {
71  [0]=>
72  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
73  [1]=>
74  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
75}
76Converted Strings:
77array(2) {
78  [0]=>
79  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
80  [1]=>
81  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
82}
83array(2) {
84  [0]=>
85  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
86  [1]=>
87  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
88}
89array(2) {
90  [0]=>
91  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
92  [1]=>
93  string(68) "GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg=="
94}
95
96-- Convert to EUC-JP --
97EUC-JP encoded string in base64:
98array(2) {
99  [0]=>
100  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
101  [1]=>
102  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
103}
104Converted Strings:
105array(2) {
106  [0]=>
107  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
108  [1]=>
109  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
110}
111array(2) {
112  [0]=>
113  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
114  [1]=>
115  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
116}
117array(2) {
118  [0]=>
119  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
120  [1]=>
121  string(52) "xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=="
122}
123
124-- Convert to SJIS --
125SJIS encoded string in base64:
126array(2) {
127  [0]=>
128  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
129  [1]=>
130  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
131}
132Converted Strings:
133array(2) {
134  [0]=>
135  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
136  [1]=>
137  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
138}
139array(2) {
140  [0]=>
141  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
142  [1]=>
143  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
144}
145array(2) {
146  [0]=>
147  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
148  [1]=>
149  string(52) "k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=="
150}
151
152-- Convert to UTF-8 --
153UTF-8 encoded string in base64:
154array(2) {
155  [0]=>
156  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
157  [1]=>
158  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
159}
160Converted Strings:
161array(2) {
162  [0]=>
163  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
164  [1]=>
165  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
166}
167array(2) {
168  [0]=>
169  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
170  [1]=>
171  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
172}
173array(2) {
174  [0]=>
175  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
176  [1]=>
177  string(72) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
178}
179Done
180