Refactor getCodepoint() to more consistently handle return values
Change-Id: Ida90e6c78be41e8527eaefd14feb45c57413945e
This commit is contained in:
@@ -75,11 +75,16 @@ class LanguageNameSearch {
|
|||||||
$values = array();
|
$values = array();
|
||||||
$lookingFor = 1;
|
$lookingFor = 1;
|
||||||
$strLen = strlen( $str );
|
$strLen = strlen( $str );
|
||||||
|
$number = 0;
|
||||||
|
|
||||||
for ( $i = 0; $i < $strLen; $i++ ) {
|
for ( $i = 0; $i < $strLen; $i++ ) {
|
||||||
$thisValue = ord( $str[$i] );
|
$thisValue = ord( $str[$i] );
|
||||||
if ( $thisValue < 128 ) {
|
if ( $thisValue < 128 ) {
|
||||||
return $thisValue;
|
$number = $thisValue;
|
||||||
} else { // Codepoints larger than 127 are represented by multi-byte sequences
|
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// Codepoints larger than 127 are represented by multi-byte sequences
|
||||||
if ( count( $values ) === 0 ) {
|
if ( count( $values ) === 0 ) {
|
||||||
// 224 is the lowest non-overlong-encoded codepoint.
|
// 224 is the lowest non-overlong-encoded codepoint.
|
||||||
$lookingFor = ( $thisValue < 224 ) ? 2 : 3;
|
$lookingFor = ( $thisValue < 224 ) ? 2 : 3;
|
||||||
@@ -97,10 +102,12 @@ class LanguageNameSearch {
|
|||||||
$number += $values[1] % 64;
|
$number += $values[1] % 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $number;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user