mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 13:26:07 +03:00
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
|
||||
* @return integer
|
||||
* @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
|
||||
@ -771,6 +806,6 @@ class PHPExcel_Shared_String
|
||||
if (is_numeric($value))
|
||||
return $value;
|
||||
$v = floatval($value);
|
||||
return (is_numeric(substr($value,0,strlen($v)))) ? $v : $value;
|
||||
return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
|
||||
}
|
||||
}
|
||||
|
@ -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
Block a user