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  TRUE,
33  FALSE,
34);
35
36$count = 0;
37/* loop through to check possible variations */
38foreach ($strings as $string) {
39  echo "\n-- Iteration $count --\n";
40  var_dump( strtoupper($string) );
41  $count++;
42}
43
44echo "\n*** Testing strtoupper() with two different case strings ***\n";
45if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD"))
46  echo "strings are same, with Case Insensitive\n";
47else
48  echo "strings are not same\n";
49
50echo "*** Done ***";
51?>
52--EXPECTF--
53*** Testing strtoupper() with all 256 chars ***
5400 => 00
5501 => 01
5602 => 02
5703 => 03
5804 => 04
5905 => 05
6006 => 06
6107 => 07
6208 => 08
6309 => 09
640a => 0a
650b => 0b
660c => 0c
670d => 0d
680e => 0e
690f => 0f
7010 => 10
7111 => 11
7212 => 12
7313 => 13
7414 => 14
7515 => 15
7616 => 16
7717 => 17
7818 => 18
7919 => 19
801a => 1a
811b => 1b
821c => 1c
831d => 1d
841e => 1e
851f => 1f
8620 => 20
8721 => 21
8822 => 22
8923 => 23
9024 => 24
9125 => 25
9226 => 26
9327 => 27
9428 => 28
9529 => 29
962a => 2a
972b => 2b
982c => 2c
992d => 2d
1002e => 2e
1012f => 2f
10230 => 30
10331 => 31
10432 => 32
10533 => 33
10634 => 34
10735 => 35
10836 => 36
10937 => 37
11038 => 38
11139 => 39
1123a => 3a
1133b => 3b
1143c => 3c
1153d => 3d
1163e => 3e
1173f => 3f
11840 => 40
11941 => 41
12042 => 42
12143 => 43
12244 => 44
12345 => 45
12446 => 46
12547 => 47
12648 => 48
12749 => 49
1284a => 4a
1294b => 4b
1304c => 4c
1314d => 4d
1324e => 4e
1334f => 4f
13450 => 50
13551 => 51
13652 => 52
13753 => 53
13854 => 54
13955 => 55
14056 => 56
14157 => 57
14258 => 58
14359 => 59
1445a => 5a
1455b => 5b
1465c => 5c
1475d => 5d
1485e => 5e
1495f => 5f
15060 => 60
15161 => 41
15262 => 42
15363 => 43
15464 => 44
15565 => 45
15666 => 46
15767 => 47
15868 => 48
15969 => 49
1606a => 4a
1616b => 4b
1626c => 4c
1636d => 4d
1646e => 4e
1656f => 4f
16670 => 50
16771 => 51
16872 => 52
16973 => 53
17074 => 54
17175 => 55
17276 => 56
17377 => 57
17478 => 58
17579 => 59
1767a => 5a
1777b => 7b
1787c => 7c
1797d => 7d
1807e => 7e
1817f => 7f
18280 => 80
18381 => 81
18482 => 82
18583 => 83
18684 => 84
18785 => 85
18886 => 86
18987 => 87
19088 => 88
19189 => 89
1928a => 8a
1938b => 8b
1948c => 8c
1958d => 8d
1968e => 8e
1978f => 8f
19890 => 90
19991 => 91
20092 => 92
20193 => 93
20294 => 94
20395 => 95
20496 => 96
20597 => 97
20698 => 98
20799 => 99
2089a => 8a
2099b => 9b
2109c => 8c
2119d => 9d
2129e => 8e
2139f => 9f
214a0 => a0
215a1 => a1
216a2 => a2
217a3 => a3
218a4 => a4
219a5 => a5
220a6 => a6
221a7 => a7
222a8 => a8
223a9 => a9
224aa => aa
225ab => ab
226ac => ac
227ad => ad
228ae => ae
229af => af
230b0 => b0
231b1 => b1
232b2 => b2
233b3 => b3
234b4 => b4
235b5 => b5
236b6 => b6
237b7 => b7
238b8 => b8
239b9 => b9
240ba => ba
241bb => bb
242bc => bc
243bd => bd
244be => be
245bf => bf
246c0 => c0
247c1 => c1
248c2 => c2
249c3 => c3
250c4 => c4
251c5 => c5
252c6 => c6
253c7 => c7
254c8 => c8
255c9 => c9
256ca => ca
257cb => cb
258cc => cc
259cd => cd
260ce => ce
261cf => cf
262d0 => d0
263d1 => d1
264d2 => d2
265d3 => d3
266d4 => d4
267d5 => d5
268d6 => d6
269d7 => d7
270d8 => d8
271d9 => d9
272da => da
273db => db
274dc => dc
275dd => dd
276de => de
277df => df
278e0 => c0
279e1 => c1
280e2 => c2
281e3 => c3
282e4 => c4
283e5 => c5
284e6 => c6
285e7 => c7
286e8 => c8
287e9 => c9
288ea => ca
289eb => cb
290ec => cc
291ed => cd
292ee => ce
293ef => cf
294f0 => d0
295f1 => d1
296f2 => d2
297f3 => d3
298f4 => d4
299f5 => d5
300f6 => d6
301f7 => f7
302f8 => d8
303f9 => d9
304fa => da
305fb => db
306fc => dc
307fd => dd
308fe => de
309ff => 9f
310
311*** Testing strtoupper() with basic strings ***
312string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
313"
314
315*** Testing strtoupper() with various strings ***
316-- Iteration 0 --
317string(0) ""
318
319-- Iteration 1 --
320string(6) "STRING"
321
322-- Iteration 2 --
323string(10) "STRING0234"
324
325-- Iteration 3 --
326string(20) "1.233.344STRING12333"
327
328-- Iteration 4 --
329string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
330
331-- Iteration 5 --
332string(13) "ABCD%0ABCDABCD"
333
334-- Iteration 6 --
335string(1) "1"
336
337-- Iteration 7 --
338string(0) ""
339
340*** Testing strtoupper() with two different case strings ***
341strings are same, with Case Insensitive
342*** Done ***
343