7
7
/**
8
8
* UTF-8 aware alternative to ord
9
9
* Returns the unicode ordinal for a character
10
+ *
11
+ * Joomla modification - As of PHP 7.4, curly brace access has been deprecated. As a result this function has been
12
+ * modified to use square brace syntax
13
+ * See https://github.com/php/php-src/commit/d574df63dc375f5fc9202ce5afde23f866b6450a
14
+ * for additional references
15
+ *
10
16
* @param string UTF-8 encoded character
11
17
* @return int unicode ordinal for the character
12
18
* @see http://www.php.net/ord
@@ -20,33 +26,33 @@ function utf8_ord($chr) {
20
26
return $ ord0 ;
21
27
}
22
28
23
- if ( !isset ($ chr{ 1 } ) ) {
29
+ if ( !isset ($ chr[ 1 ] ) ) {
24
30
trigger_error ('Short sequence - at least 2 bytes expected, only 1 seen ' );
25
31
return FALSE ;
26
32
}
27
33
28
- $ ord1 = ord($ chr{ 1 } );
34
+ $ ord1 = ord ($ chr[ 1 ] );
29
35
if ( $ ord0 >= 192 && $ ord0 <= 223 ) {
30
36
return ( $ ord0 - 192 ) * 64
31
37
+ ( $ ord1 - 128 );
32
38
}
33
39
34
- if ( !isset ($ chr{ 2 } ) ) {
40
+ if ( !isset ($ chr[ 2 ] ) ) {
35
41
trigger_error ('Short sequence - at least 3 bytes expected, only 2 seen ' );
36
42
return FALSE ;
37
43
}
38
- $ ord2 = ord($ chr{ 2 } );
44
+ $ ord2 = ord ($ chr[ 2 ] );
39
45
if ( $ ord0 >= 224 && $ ord0 <= 239 ) {
40
46
return ($ ord0 -224 )*4096
41
47
+ ($ ord1 -128 )*64
42
48
+ ($ ord2 -128 );
43
49
}
44
50
45
- if ( !isset ($ chr{ 3 } ) ) {
51
+ if ( !isset ($ chr[ 3 ] ) ) {
46
52
trigger_error ('Short sequence - at least 4 bytes expected, only 3 seen ' );
47
53
return FALSE ;
48
54
}
49
- $ ord3 = ord($ chr{ 3 } );
55
+ $ ord3 = ord ($ chr[ 3 ] );
50
56
if ($ ord0 >=240 && $ ord0 <=247 ) {
51
57
return ($ ord0 -240 )*262144
52
58
+ ($ ord1 -128 )*4096
@@ -55,11 +61,11 @@ function utf8_ord($chr) {
55
61
56
62
}
57
63
58
- if ( !isset ($ chr{ 4 } ) ) {
64
+ if ( !isset ($ chr[ 4 ] ) ) {
59
65
trigger_error ('Short sequence - at least 5 bytes expected, only 4 seen ' );
60
66
return FALSE ;
61
67
}
62
- $ ord4 = ord($ chr{ 4 } );
68
+ $ ord4 = ord ($ chr[ 4 ] );
63
69
if ($ ord0 >=248 && $ ord0 <=251 ) {
64
70
return ($ ord0 -248 )*16777216
65
71
+ ($ ord1 -128 )*262144
@@ -68,7 +74,7 @@ function utf8_ord($chr) {
68
74
+ ($ ord4 -128 );
69
75
}
70
76
71
- if ( !isset ($ chr{ 5 } ) ) {
77
+ if ( !isset ($ chr[ 5 ] ) ) {
72
78
trigger_error ('Short sequence - at least 6 bytes expected, only 5 seen ' );
73
79
return FALSE ;
74
80
}
@@ -78,7 +84,7 @@ function utf8_ord($chr) {
78
84
+ ($ ord2 -128 )*262144
79
85
+ ($ ord3 -128 )*4096
80
86
+ ($ ord4 -128 )*64
81
- + (ord ($ chr{ 5 } )-128 );
87
+ + (ord ($ chr[ 5 ] )-128 );
82
88
}
83
89
84
90
if ( $ ord0 >= 254 && $ ord0 <= 255 ) {
0 commit comments