1--TEST--
2Test strtoupper() function
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != "WIN" || !setlocale(LC_CTYPE, "English_United States.1252"))
6  die('skip Run only on Windows with locale "English_United States.1252" available');
7?>
8--FILE--
9<?php
10
11setlocale(LC_CTYPE, "English_United States.1252");
12
13echo "*** Testing strtoupper() with all 256 chars ***\n";
14for ($i=0; $i<=255; $i++){
15  $char = chr($i);
16  print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n";
17}
18
19echo "\n*** Testing strtoupper() with basic strings ***\n";
20$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
21var_dump(strtoupper($str));
22
23echo "\n*** Testing strtoupper() with various strings ***";
24/* strings to pass strtoupper() */
25$strings = array (
26  "",
27  "string",
28  "stRINg0234",
29  "1.233.344StrinG12333",
30  "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
31  "ABCD\0abcdABCD",
32  NULL,
33  TRUE,
34  FALSE,
35);
36
37$count = 0;
38/* loop through to check possible variations */
39foreach ($strings as $string) {
40  echo "\n-- Iteration $count --\n";
41  var_dump( strtoupper($string) );
42  $count++;
43}
44
45echo "\n*** Testing strtoupper() with two different case strings ***\n";
46if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD"))
47  echo "strings are same, with Case Insensitive\n";
48else
49  echo "strings are not same\n";
50
51echo "*** Done ***";
52?>
53--EXPECT--
54*** Testing strtoupper() with all 256 chars ***
5500 => 00
5601 => 01
5702 => 02
5803 => 03
5904 => 04
6005 => 05
6106 => 06
6207 => 07
6308 => 08
6409 => 09
650a => 0a
660b => 0b
670c => 0c
680d => 0d
690e => 0e
700f => 0f
7110 => 10
7211 => 11
7312 => 12
7413 => 13
7514 => 14
7615 => 15
7716 => 16
7817 => 17
7918 => 18
8019 => 19
811a => 1a
821b => 1b
831c => 1c
841d => 1d
851e => 1e
861f => 1f
8720 => 20
8821 => 21
8922 => 22
9023 => 23
9124 => 24
9225 => 25
9326 => 26
9427 => 27
9528 => 28
9629 => 29
972a => 2a
982b => 2b
992c => 2c
1002d => 2d
1012e => 2e
1022f => 2f
10330 => 30
10431 => 31
10532 => 32
10633 => 33
10734 => 34
10835 => 35
10936 => 36
11037 => 37
11138 => 38
11239 => 39
1133a => 3a
1143b => 3b
1153c => 3c
1163d => 3d
1173e => 3e
1183f => 3f
11940 => 40
12041 => 41
12142 => 42
12243 => 43
12344 => 44
12445 => 45
12546 => 46
12647 => 47
12748 => 48
12849 => 49
1294a => 4a
1304b => 4b
1314c => 4c
1324d => 4d
1334e => 4e
1344f => 4f
13550 => 50
13651 => 51
13752 => 52
13853 => 53
13954 => 54
14055 => 55
14156 => 56
14257 => 57
14358 => 58
14459 => 59
1455a => 5a
1465b => 5b
1475c => 5c
1485d => 5d
1495e => 5e
1505f => 5f
15160 => 60
15261 => 41
15362 => 42
15463 => 43
15564 => 44
15665 => 45
15766 => 46
15867 => 47
15968 => 48
16069 => 49
1616a => 4a
1626b => 4b
1636c => 4c
1646d => 4d
1656e => 4e
1666f => 4f
16770 => 50
16871 => 51
16972 => 52
17073 => 53
17174 => 54
17275 => 55
17376 => 56
17477 => 57
17578 => 58
17679 => 59
1777a => 5a
1787b => 7b
1797c => 7c
1807d => 7d
1817e => 7e
1827f => 7f
18380 => 80
18481 => 81
18582 => 82
18683 => 83
18784 => 84
18885 => 85
18986 => 86
19087 => 87
19188 => 88
19289 => 89
1938a => 8a
1948b => 8b
1958c => 8c
1968d => 8d
1978e => 8e
1988f => 8f
19990 => 90
20091 => 91
20192 => 92
20293 => 93
20394 => 94
20495 => 95
20596 => 96
20697 => 97
20798 => 98
20899 => 99
2099a => 8a
2109b => 9b
2119c => 8c
2129d => 9d
2139e => 8e
2149f => 9f
215a0 => a0
216a1 => a1
217a2 => a2
218a3 => a3
219a4 => a4
220a5 => a5
221a6 => a6
222a7 => a7
223a8 => a8
224a9 => a9
225aa => aa
226ab => ab
227ac => ac
228ad => ad
229ae => ae
230af => af
231b0 => b0
232b1 => b1
233b2 => b2
234b3 => b3
235b4 => b4
236b5 => b5
237b6 => b6
238b7 => b7
239b8 => b8
240b9 => b9
241ba => ba
242bb => bb
243bc => bc
244bd => bd
245be => be
246bf => bf
247c0 => c0
248c1 => c1
249c2 => c2
250c3 => c3
251c4 => c4
252c5 => c5
253c6 => c6
254c7 => c7
255c8 => c8
256c9 => c9
257ca => ca
258cb => cb
259cc => cc
260cd => cd
261ce => ce
262cf => cf
263d0 => d0
264d1 => d1
265d2 => d2
266d3 => d3
267d4 => d4
268d5 => d5
269d6 => d6
270d7 => d7
271d8 => d8
272d9 => d9
273da => da
274db => db
275dc => dc
276dd => dd
277de => de
278df => df
279e0 => c0
280e1 => c1
281e2 => c2
282e3 => c3
283e4 => c4
284e5 => c5
285e6 => c6
286e7 => c7
287e8 => c8
288e9 => c9
289ea => ca
290eb => cb
291ec => cc
292ed => cd
293ee => ce
294ef => cf
295f0 => d0
296f1 => d1
297f2 => d2
298f3 => d3
299f4 => d4
300f5 => d5
301f6 => d6
302f7 => f7
303f8 => d8
304f9 => d9
305fa => da
306fb => db
307fc => dc
308fd => dd
309fe => de
310ff => 9f
311
312*** Testing strtoupper() with basic strings ***
313string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
314"
315
316*** Testing strtoupper() with various strings ***
317-- Iteration 0 --
318string(0) ""
319
320-- Iteration 1 --
321string(6) "STRING"
322
323-- Iteration 2 --
324string(10) "STRING0234"
325
326-- Iteration 3 --
327string(20) "1.233.344STRING12333"
328
329-- Iteration 4 --
330string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
331
332-- Iteration 5 --
333string(13) "ABCD�ABCDABCD"
334
335-- Iteration 6 --
336string(0) ""
337
338-- Iteration 7 --
339string(1) "1"
340
341-- Iteration 8 --
342string(0) ""
343
344*** Testing strtoupper() with two different case strings ***
345strings are same, with Case Insensitive
346*** Done ***
347