Merge "Refactor getCodepoint() to more consistently handle return values"

This commit is contained in:
jenkins-bot
2013-08-05 15:42:53 +00:00
committed by Gerrit Code Review

View File

@@ -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;
} }
/** /**