Method for reversing the case of a string, for use in comparisons where lower-case/upper-case is reversed
This commit is contained in:
parent
c089cfd53f
commit
dc137c293a
|
@ -3641,21 +3641,19 @@ class PHPExcel_Calculation {
|
|||
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
|
||||
// And push the result onto the stack
|
||||
$stack->push('Value',$result);
|
||||
return TRUE;
|
||||
} // function _executeBinaryComparisonOperation()
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters
|
||||
* @param string $str1
|
||||
* @param string $str2
|
||||
* @param string $str1 First string value for the comparison
|
||||
* @param string $str2 Second string value for the comparison
|
||||
* @return integer
|
||||
*/
|
||||
private function strcmpLowercaseFirst($str1, $str2)
|
||||
{
|
||||
$from = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
$to = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$inversedStr1 = strtr($str1, $from, $to);
|
||||
$inversedStr2 = strtr($str2, $from, $to);
|
||||
$inversedStr1 = PHPExcel_Shared_String::StrCaseReverse($str1);
|
||||
$inversedStr2 = PHPExcel_Shared_String::StrCaseReverse($str2);
|
||||
|
||||
return strcmp($inversedStr1, $inversedStr2);
|
||||
}
|
||||
|
|
|
@ -626,6 +626,41 @@ class PHPExcel_Shared_String
|
|||
return ucwords($pValue);
|
||||
}
|
||||
|
||||
public static function mb_is_upper($char)
|
||||
{
|
||||
return mb_strtolower($char, "UTF-8") != $char;
|
||||
}
|
||||
|
||||
public static function mb_str_split($string)
|
||||
{
|
||||
# Split at all position not after the start: ^
|
||||
# and not before the end: $
|
||||
return preg_split('/(?<!^)(?!$)/u', $string );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the case of a string, so that all uppercase characters become lowercase
|
||||
* and all lowercase characters become uppercase
|
||||
*
|
||||
* @param string $pValue UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function StrCaseReverse($pValue = '')
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$characters = self::mb_str_split($pValue);
|
||||
foreach($characters as &$character) {
|
||||
if(self::mb_is_upper($character)) {
|
||||
$character = mb_strtolower($character, 'UTF-8');
|
||||
} else {
|
||||
$character = mb_strtoupper($character, 'UTF-8');
|
||||
}
|
||||
}
|
||||
return implode('', $characters);
|
||||
}
|
||||
return strtolower($pValue) ^ strtoupper($pValue) ^ $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether a string contains a fractional numeric value,
|
||||
* and convert it to a numeric if it is
|
||||
|
|
|
@ -257,7 +257,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_operator = '';
|
||||
private $_operator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
|
||||
|
||||
/**
|
||||
* DateTimeGrouping Group Value
|
||||
|
|
Loading…
Reference in New Issue