1--TEST--
2Test mb_strtolower() function : basic functionality
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7/*
8 * Test basic functionality of mb_strtolower
9 */
10
11echo "*** Testing mb_strtolower() : basic functionality***\n";
12
13$ascii_lower = 'abcdefghijklmnopqrstuvwxyz';
14$ascii_upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
15$greek_lower = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
16$greek_upper = base64_decode('zpHOks6TzpTOlc6WzpfOmM6ZzprOm86czp3Ons6fzqDOoc6jzqTOpc6mzqfOqM6p');
17
18echo "\n-- ASCII String --\n";
19$ascii = mb_strtolower($ascii_upper);
20var_dump($ascii);
21
22if($ascii == $ascii_lower) {
23    echo "Correctly converted\n";
24} else {
25    echo "Incorrectly converted\n";
26}
27
28echo "\n-- Multibyte String --\n";
29$mb = mb_strtolower($greek_upper, 'UTF-8');
30var_dump(base64_encode($mb));
31
32if ($mb == $greek_lower) {
33    echo "Correctly converted\n";
34} else {
35    echo "Incorrectly converted\n";
36}
37
38echo "\n-- Greek letter sigma --\n";
39var_dump(mb_strtolower("Σ", 'UTF-8'));
40var_dump(mb_strtolower("aΣ", 'UTF-8'));
41var_dump(mb_strtolower("aΣb", 'UTF-8'));
42var_dump(mb_strtolower("aΣ b", 'UTF-8'));
43var_dump(mb_strtolower(" ΣΣΣΣ ", 'UTF-8'));
44
45// Apostrophe, full stop, colon, etc. are "case-ignorable"
46// When checking whether capital sigma is at the end of a word or not, we skip over
47// any number of case-ignorable characters, both when scanning back and when scanning forward
48var_dump(mb_strtolower("'Σ", 'UTF-8'));
49var_dump(mb_strtolower("ab'Σ", 'UTF-8'));
50var_dump(mb_strtolower("Σ'", 'UTF-8'));
51var_dump(mb_strtolower("Σ'a", 'UTF-8'));
52var_dump(mb_strtolower("a'Σ'a", 'UTF-8'));
53
54// We scan back by at least 63 characters when necessary,
55// but there is no guarantee that we will scan back further than that
56var_dump(mb_strtolower('a' . str_repeat('.', 63) . "Σ", 'UTF-8'));
57var_dump(mb_strtolower('a' . str_repeat('.', 64) . "Σ", 'UTF-8')); // Context-sensitive casing doesn't work here!
58
59// When scanning forward to confirm if capital sigma is at the end of a word or not,
60// there is no limit as to how far we will scan
61var_dump(mb_strtolower("abcΣ" . str_repeat('.', 64) . ' abc', 'UTF-8'));
62var_dump(mb_strtolower("abcΣ" . str_repeat('.', 64) . 'a abc', 'UTF-8'));
63var_dump(mb_strtolower("abcΣ" . str_repeat('.', 256) . ' abc', 'UTF-8'));
64
65echo "Done";
66?>
67--EXPECT--
68*** Testing mb_strtolower() : basic functionality***
69
70-- ASCII String --
71string(26) "abcdefghijklmnopqrstuvwxyz"
72Correctly converted
73
74-- Multibyte String --
75string(64) "zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J"
76Correctly converted
77
78-- Greek letter sigma --
79string(2) "σ"
80string(3) "aς"
81string(4) "aσb"
82string(5) "aς b"
83string(10) " σσσς "
84string(3) "'σ"
85string(5) "ab'ς"
86string(3) "σ'"
87string(4) "σ'a"
88string(6) "a'σ'a"
89string(66) "a...............................................................ς"
90string(67) "a................................................................σ"
91string(73) "abcς................................................................ abc"
92string(74) "abcσ................................................................a abc"
93string(265) "abcς................................................................................................................................................................................................................................................................ abc"
94Done
95