From dc137c293afc3caf69d8934f06b8dc3d7c685578 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sun, 18 Jan 2015 12:31:18 +0000 Subject: [PATCH] Method for reversing the case of a string, for use in comparisons where lower-case/upper-case is reversed --- Classes/PHPExcel/Calculation.php | 16 ++++---- Classes/PHPExcel/Shared/String.php | 37 ++++++++++++++++++- .../Worksheet/AutoFilter/Column/Rule.php | 2 +- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index 7887a4a9..1b010163 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -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); } diff --git a/Classes/PHPExcel/Shared/String.php b/Classes/PHPExcel/Shared/String.php index 4921dc95..7d6b4192 100644 --- a/Classes/PHPExcel/Shared/String.php +++ b/Classes/PHPExcel/Shared/String.php @@ -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('/(?