xref: /PHP-8.0/ext/mbstring/tests/casemapping.phpt (revision 73dcfb6f)
1--TEST--
2Unicode case mapping
3--SKIPIF--
4<?php require 'skipif.inc'; ?>
5--FILE--
6<?php
7
8function toCases($str) {
9    echo "String: $str\n";
10    echo "Lower: ", mb_convert_case($str, MB_CASE_LOWER), "\n";
11    echo "Lower Simple: ", mb_convert_case($str, MB_CASE_LOWER_SIMPLE), "\n";
12    echo "Upper: ", mb_convert_case($str, MB_CASE_UPPER), "\n";
13    echo "Upper Simple: ", mb_convert_case($str, MB_CASE_UPPER_SIMPLE), "\n";
14    echo "Title: ", mb_convert_case($str, MB_CASE_TITLE), "\n";
15    echo "Title Simple: ", mb_convert_case($str, MB_CASE_TITLE_SIMPLE), "\n";
16    echo "Fold: ", mb_convert_case($str, MB_CASE_FOLD), "\n";
17    echo "Fold Simple: ", mb_convert_case($str, MB_CASE_FOLD_SIMPLE), "\n";
18    echo "\n";
19}
20
21toCases("ß");
22toCases("ff");
23toCases("İ");
24
25// Make sure that case-conversion in Turkish still works correctly.
26// Using the language-agnostic Unicode case mappings would result in
27// characters that are illegal under ISO-8859-9.
28mb_internal_encoding('ISO-8859-9');
29
30// Capital I with dot (U+0130)
31$str = "\xdd";
32echo bin2hex(mb_convert_case($str, MB_CASE_LOWER)), "\n";
33echo bin2hex(mb_convert_case($str, MB_CASE_LOWER_SIMPLE)), "\n";
34echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
35echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
36echo "\n";
37
38// Lower i without dot (U+0131)
39$str = "\xfd";
40echo bin2hex(mb_convert_case($str, MB_CASE_UPPER)), "\n";
41echo bin2hex(mb_convert_case($str, MB_CASE_UPPER_SIMPLE)), "\n";
42echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
43echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
44echo "\n";
45
46// Capital I without dot (U+0049)
47$str = "\x49";
48echo bin2hex(mb_convert_case($str, MB_CASE_LOWER)), "\n";
49echo bin2hex(mb_convert_case($str, MB_CASE_LOWER_SIMPLE)), "\n";
50echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
51echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
52echo "\n";
53
54// Lower i with dot (U+0069)
55$str = "\x69";
56echo bin2hex(mb_convert_case($str, MB_CASE_UPPER)), "\n";
57echo bin2hex(mb_convert_case($str, MB_CASE_UPPER_SIMPLE)), "\n";
58echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
59echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
60
61?>
62--EXPECT--
63String: ß
64Lower: ß
65Lower Simple: ß
66Upper: SS
67Upper Simple: ß
68Title: Ss
69Title Simple: ß
70Fold: ss
71Fold Simple: ß
72
73String: ff
74Lower: ff
75Lower Simple: ff
76Upper: FF
77Upper Simple: ff
78Title: Ff
79Title Simple: ff
80Fold: ff
81Fold Simple: ff
82
83String: İ
84Lower: i̇
85Lower Simple: i
86Upper: İ
87Upper Simple: İ
88Title: İ
89Title Simple: İ
90Fold: i̇
91Fold Simple: İ
92
9369
9469
9569
9669
97
9849
9949
100fd
101fd
102
103fd
104fd
105fd
106fd
107
108dd
109dd
11069
11169
112