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