File: mb_strtoupper_variation3.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (49 lines) | stat: -rw-r--r-- 1,593 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
Test mb_strtoupper() function : usage varitations - pass mixed ASCII and non-ASCII strings
--EXTENSIONS--
mbstring
--FILE--
<?php
/*
 * Pass a Japanese string and a mixed Japanese and ASCII string to mb_strtolower
 * to check correct conversion is occurring (Japanese characters should not be converted).
 */

echo "*** Testing mb_strtoupper() : usage variations ***\n";

$string_mixed_upper = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCUEhQLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg==');
$string_mixed_lower = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCcGhwLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg==');
$string_all_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CC');


echo "\n-- Mixed string (mulitbyte and ASCII characters) --\n";
$a = mb_strtoupper($string_mixed_lower, 'UTF-8');
var_dump(base64_encode($a));
if ($a == $string_mixed_upper) {
    echo "Correctly Converted\n";
} else {
    echo "Incorrectly Converted\n";
}

echo "\n-- Multibyte Only String--\n";
$b = mb_strtoupper($string_all_mb, 'UTF-8');
var_dump(base64_encode($b));
if ($b == $string_all_mb) { // Japanese characters only - should not be any conversion
    echo "Correctly Converted\n";
} else {
    echo "Incorrectly Converted\n";
}

echo "Done";
?>
--EXPECT--
*** Testing mb_strtoupper() : usage variations ***

-- Mixed string (mulitbyte and ASCII characters) --
string(80) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCUEhQLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg=="
Correctly Converted

-- Multibyte Only String--
string(40) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CC"
Correctly Converted
Done