Remove the final pieces of default charset.
authorJan Schneider <jan@horde.org>
Sun, 3 Oct 2010 17:51:55 +0000 (19:51 +0200)
committerJan Schneider <jan@horde.org>
Sun, 3 Oct 2010 17:52:15 +0000 (19:52 +0200)
agora/lib/Messages.php
framework/SpellChecker/lib/Horde/SpellChecker.php
framework/Util/lib/Horde/Array/Sort/Helper.php
framework/Util/lib/Horde/String.php
horde/util/barcode.php
turba/lib/List.php

index 920fffc..a7ae704 100644 (file)
@@ -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. */
index d0000f2..eedcfd2 100644 (file)
@@ -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);
     }
 
 }
index 314ce74..c05222d 100644 (file)
@@ -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'));
     }
 
 }
index dd2baea..02c456c 100644 (file)
 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));
index 41c78d3..721d0d1 100644 (file)
@@ -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);
index 4b616e7..157877b 100644 (file)
@@ -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.