Skip to content

Commit d36c15c

Browse files
committed
Merge branch 'master' into 2.0-dev
2 parents 2e09dff + 33944ac commit d36c15c

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.phar
33
composer.lock
44
phpunit.xml
55
.phpunit.result.cache
6+
.idea/

src/phputf8/ord.php

+16-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
/**
88
* UTF-8 aware alternative to ord
99
* 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+
*
1016
* @param string UTF-8 encoded character
1117
* @return int unicode ordinal for the character
1218
* @see http://www.php.net/ord
@@ -20,33 +26,33 @@ function utf8_ord($chr) {
2026
return $ord0;
2127
}
2228

23-
if ( !isset($chr{1}) ) {
29+
if ( !isset($chr[1]) ) {
2430
trigger_error('Short sequence - at least 2 bytes expected, only 1 seen');
2531
return FALSE;
2632
}
2733

28-
$ord1 = ord($chr{1});
34+
$ord1 = ord($chr[1]);
2935
if ( $ord0 >= 192 && $ord0 <= 223 ) {
3036
return ( $ord0 - 192 ) * 64
3137
+ ( $ord1 - 128 );
3238
}
3339

34-
if ( !isset($chr{2}) ) {
40+
if ( !isset($chr[2]) ) {
3541
trigger_error('Short sequence - at least 3 bytes expected, only 2 seen');
3642
return FALSE;
3743
}
38-
$ord2 = ord($chr{2});
44+
$ord2 = ord($chr[2]);
3945
if ( $ord0 >= 224 && $ord0 <= 239 ) {
4046
return ($ord0-224)*4096
4147
+ ($ord1-128)*64
4248
+ ($ord2-128);
4349
}
4450

45-
if ( !isset($chr{3}) ) {
51+
if ( !isset($chr[3]) ) {
4652
trigger_error('Short sequence - at least 4 bytes expected, only 3 seen');
4753
return FALSE;
4854
}
49-
$ord3 = ord($chr{3});
55+
$ord3 = ord($chr[3]);
5056
if ($ord0>=240 && $ord0<=247) {
5157
return ($ord0-240)*262144
5258
+ ($ord1-128)*4096
@@ -55,11 +61,11 @@ function utf8_ord($chr) {
5561

5662
}
5763

58-
if ( !isset($chr{4}) ) {
64+
if ( !isset($chr[4]) ) {
5965
trigger_error('Short sequence - at least 5 bytes expected, only 4 seen');
6066
return FALSE;
6167
}
62-
$ord4 = ord($chr{4});
68+
$ord4 = ord($chr[4]);
6369
if ($ord0>=248 && $ord0<=251) {
6470
return ($ord0-248)*16777216
6571
+ ($ord1-128)*262144
@@ -68,7 +74,7 @@ function utf8_ord($chr) {
6874
+ ($ord4-128);
6975
}
7076

71-
if ( !isset($chr{5}) ) {
77+
if ( !isset($chr[5]) ) {
7278
trigger_error('Short sequence - at least 6 bytes expected, only 5 seen');
7379
return FALSE;
7480
}
@@ -78,7 +84,7 @@ function utf8_ord($chr) {
7884
+ ($ord2-128)*262144
7985
+ ($ord3-128)*4096
8086
+ ($ord4-128)*64
81-
+ (ord($chr{5})-128);
87+
+ (ord($chr[5])-128);
8288
}
8389

8490
if ( $ord0 >= 254 && $ord0 <= 255 ) {

src/phputf8/utils/validation.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ function utf8_is_valid($str) {
3737

3838
for($i = 0; $i < $len; $i++) {
3939

40-
$in = ord($str{$i});
40+
/*
41+
* Joomla modification - As of PHP 7.4, curly brace access has been deprecated. As a result the line below has
42+
* been modified to use square brace syntax
43+
* See https://github.com/php/php-src/commit/d574df63dc375f5fc9202ce5afde23f866b6450a
44+
* for additional references
45+
*/
46+
$in = ord($str[$i]);
4147

4248
if ( $mState == 0) {
4349

0 commit comments

Comments
 (0)