From a82aefe999991997736e871cd5931d96f6369fa9 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sun, 3 Oct 2010 19:51:55 +0200 Subject: [PATCH] Remove the final pieces of default charset. --- agora/lib/Messages.php | 2 +- framework/SpellChecker/lib/Horde/SpellChecker.php | 2 +- framework/Util/lib/Horde/Array/Sort/Helper.php | 8 +++--- framework/Util/lib/Horde/String.php | 35 ++++------------------- horde/util/barcode.php | 2 +- turba/lib/List.php | 4 +-- 6 files changed, 15 insertions(+), 38 deletions(-) diff --git a/agora/lib/Messages.php b/agora/lib/Messages.php index 920fffc4b..a7ae704ec 100644 --- a/agora/lib/Messages.php +++ b/agora/lib/Messages.php @@ -2121,7 +2121,7 @@ class Agora_Messages { } if (!empty($filter['author'])) { - $sql .= ' AND message_author = ' . $this->_db->quote(Horde_String::lower($filter['author'], 'UTF-8')); + $sql .= ' AND message_author = ' . $this->_db->quote(Horde_String::lower($filter['author'])); } /* Sort by result column. */ diff --git a/framework/SpellChecker/lib/Horde/SpellChecker.php b/framework/SpellChecker/lib/Horde/SpellChecker.php index d0000f2a5..eedcfd251 100644 --- a/framework/SpellChecker/lib/Horde/SpellChecker.php +++ b/framework/SpellChecker/lib/Horde/SpellChecker.php @@ -124,7 +124,7 @@ abstract class Horde_SpellChecker { return (empty($this->_localDict)) ? false - : in_array(Horde_String::lower($word, true), $this->_localDict); + : in_array(Horde_String::lower($word, true, 'UTF-8'), $this->_localDict); } } diff --git a/framework/Util/lib/Horde/Array/Sort/Helper.php b/framework/Util/lib/Horde/Array/Sort/Helper.php index 314ce7437..c05222d4e 100644 --- a/framework/Util/lib/Horde/Array/Sort/Helper.php +++ b/framework/Util/lib/Horde/Array/Sort/Helper.php @@ -31,7 +31,7 @@ class Horde_Array_Sort_Helper */ public function compare($a, $b) { - return strcoll(Horde_String::lower($a[$this->key], true), Horde_String::lower($b[$this->key], true)); + return strcoll(Horde_String::lower($a[$this->key], true, 'UTF-8'), Horde_String::lower($b[$this->key], true, 'UTF-8')); } /** @@ -45,7 +45,7 @@ class Horde_Array_Sort_Helper */ public function reverseCompare($a, $b) { - return strcoll(Horde_String::lower($b[$this->key], true), Horde_String::lower($a[$this->key], true)); + return strcoll(Horde_String::lower($b[$this->key], true, 'UTF-8'), Horde_String::lower($a[$this->key], true, 'UTF-8')); } /** @@ -58,7 +58,7 @@ class Horde_Array_Sort_Helper */ public function compareKeys($a, $b) { - return strcoll(Horde_String::lower($a, true), Horde_String::lower($b, true)); + return strcoll(Horde_String::lower($a, true, 'UTF-8'), Horde_String::lower($b, true, 'UTF-8')); } /** @@ -71,7 +71,7 @@ class Horde_Array_Sort_Helper */ public function reverseCompareKeys($a, $b) { - return strcoll(Horde_String::lower($b, true), Horde_String::lower($a, true)); + return strcoll(Horde_String::lower($b, true, 'UTF-8'), Horde_String::lower($a, true, 'UTF-8')); } } diff --git a/framework/Util/lib/Horde/String.php b/framework/Util/lib/Horde/String.php index dd2baeab0..02c456c7c 100644 --- a/framework/Util/lib/Horde/String.php +++ b/framework/Util/lib/Horde/String.php @@ -16,13 +16,6 @@ class Horde_String { /** - * Default charset. - * - * @var string - */ - static protected $_charset = 'UTF-8'; - - /** * lower() cache. * * @var array @@ -47,9 +40,7 @@ class Horde_String * @param mixed $input The data to be converted. If $input is an an array, * the array's values get converted recursively. * @param string $from The string's current charset. - * @param string $to The charset to convert the string to. If not - * specified, the global variable $_charset will - * be used. + * @param string $to The charset to convert the string to. * * @return mixed The converted input data. */ @@ -195,7 +186,7 @@ class Horde_String if ($locale) { if (Horde_Util::extensionExists('mbstring')) { if (is_null($charset)) { - $charset = self::$_charset; + throw new InvalidArgumentException('$charset argument must not be null'); } $old_error = error_reporting(0); $ret = mb_strtolower($string, self::_mbstringCharset($charset)); @@ -233,7 +224,7 @@ class Horde_String if ($locale) { if (Horde_Util::extensionExists('mbstring')) { if (is_null($charset)) { - $charset = self::$_charset; + throw new InvalidArgumentException('$charset argument must not be null'); } $old_error = error_reporting(0); $ret = mb_strtoupper($string, self::_mbstringCharset($charset)); @@ -293,7 +284,7 @@ class Horde_String * @return string The string's part. */ static public function substr($string, $start, $length = null, - $charset = null) + $charset = 'UTF-8') { if (is_null($length)) { $length = self::length($string, $charset) - $start; @@ -305,10 +296,6 @@ class Horde_String /* Try iconv. */ if (Horde_Util::extensionExists('iconv')) { - if (is_null($charset)) { - $charset = self::$_charset; - } - $old_error = error_reporting(0); $ret = iconv_substr($string, $start, $length, $charset); error_reporting($old_error); @@ -321,9 +308,6 @@ class Horde_String /* Try mbstring. */ if (Horde_Util::extensionExists('mbstring')) { - if (is_null($charset)) { - $charset = self::$_charset; - } $old_error = error_reporting(0); $ret = mb_substr($string, $start, $length, self::_mbstringCharset($charset)); error_reporting($old_error); @@ -346,11 +330,8 @@ class Horde_String * * @return integer The string's length. */ - static public function length($string, $charset = null) + static public function length($string, $charset == 'UTF-8') { - if (is_null($charset)) { - $charset = self::$_charset; - } $charset = self::lower($charset); if ($charset == 'utf-8' || $charset == 'utf8') { @@ -382,13 +363,9 @@ class Horde_String * * @return integer The position of first occurrence. */ - static public function pos($haystack, $needle, $offset = 0, - $charset = null) + static public function pos($haystack, $needle, $offset, $charset = 'UTF-8') { if (Horde_Util::extensionExists('mbstring')) { - if (is_null($charset)) { - $charset = self::$_charset; - } $track_errors = ini_set('track_errors', 1); $old_error = error_reporting(0); $ret = mb_strpos($haystack, $needle, $offset, self::_mbstringCharset($charset)); diff --git a/horde/util/barcode.php b/horde/util/barcode.php index 41c78d3d3..721d0d103 100644 --- a/horde/util/barcode.php +++ b/horde/util/barcode.php @@ -18,7 +18,7 @@ Horde_Registry::appInit('horde', array('authentication' => 'none')); $vars = Horde_Variables::getDefaultVariables(); // Get text, uppercase, add start/stop characters. -$text = '*' . Horde_String::upper($vars->get('barcode', 'test'), true) . '*'; +$text = '*' . Horde_String::upper($vars->get('barcode', 'test'), true, 'UTF-8') . '*'; $textlen = strlen($text); $height = $vars->get('h', 40); diff --git a/turba/lib/List.php b/turba/lib/List.php index 4b616e783..157877bc7 100644 --- a/turba/lib/List.php +++ b/turba/lib/List.php @@ -177,10 +177,10 @@ class Turba_List implements Countable case 'text': if (!isset($a->sortValue[$field])) { - $a->sortValue[$field] = Horde_String::lower($a->getValue($field), true); + $a->sortValue[$field] = Horde_String::lower($a->getValue($field), true, 'UTF-8'); } if (!isset($b->sortValue[$field])) { - $b->sortValue[$field] = Horde_String::lower($b->getValue($field), true); + $b->sortValue[$field] = Horde_String::lower($b->getValue($field), true, 'UTF-8'); } // Use strcoll for locale-safe comparisons. -- 2.11.0