Move convertToUtf8() from Horde_Util:: to Horde_String::
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 10 Mar 2010 01:33:26 +0000 (18:33 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 10 Mar 2010 01:33:37 +0000 (18:33 -0700)
framework/Serialize/lib/Horde/Serialize.php
framework/Util/lib/Horde/String.php
framework/Util/lib/Horde/Util.php
framework/Util/package.xml

index b5cd84e..be7a40a 100644 (file)
@@ -260,7 +260,7 @@ class Horde_Serialize
              * data. */
             if (function_exists('json_last_error') &&
                 (json_last_error() == 5)) {
-                $data = json_encode(Horde_Util::convertToUtf8($data));
+                $data = json_encode(Horde_String::convertToUtf8($data));
             } else {
                 $data = $tmp;
             }
index a988135..e926fc3 100644 (file)
@@ -737,4 +737,32 @@ class Horde_String
         return $charset;
     }
 
+    /**
+     * Convert a variable to UTF-8. Recursively handles inner variables.
+     *
+     * @param mixed $in  The variable to convert.
+     *
+     * @return mixed  The converted variable.
+     */
+    static public function convertToUtf8($in)
+    {
+        if (is_string($in)) {
+            if (Horde_Util::extensionExists('xml')) {
+                $in = utf8_encode($in);
+            }
+        } elseif (is_array($in)) {
+            reset($in);
+            while (list($key, $val) = each($in)) {
+                $in[$key] = self::convertToUtf8($in[$key]);
+            }
+        } elseif (is_object($in)) {
+            $in = self::cloneObject($in);
+            foreach (get_object_vars($in) as $key => $val) {
+                $in->$key = self::convertToUtf8($in->$key);
+            }
+        }
+
+        return $in;
+    }
+
 }
index cccea44..2dca95a 100644 (file)
@@ -780,32 +780,4 @@ class Horde_Util
         return '';
     }
 
-    /**
-     * Convert a variable to UTF-8. Recursively handles inner variables.
-     *
-     * @param mixed $in  The variable to convert.
-     *
-     * @return mixed  The converted variable.
-     */
-    static public function convertToUtf8($in)
-    {
-        if (is_string($in)) {
-            if (self::extensionExists('xml')) {
-                $in = utf8_encode($in);
-            }
-        } elseif (is_array($in)) {
-            reset($in);
-            while (list($key, $val) = each($in)) {
-                $in[$key] = self::convertToUtf8($in[$key]);
-            }
-        } elseif (is_object($in)) {
-            $in = self::cloneObject($in);
-            foreach (get_object_vars($in) as $key => $val) {
-                $in->$key = self::convertToUtf8($in->$key);
-            }
-        }
-
-        return $in;
-    }
-
 }
index f5d37e3..a7aefb8 100644 (file)
@@ -32,7 +32,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <notes>* Removed Horde_Util::uriB64Encode() and Horde_Util::uriB64Decode().
  * Removed Horde_Util::strftime2date() and Horde_Util::date2strftime().
  * Removed Horde_Util::closeWindowJs() and Horde_Util::nocacheUrl().
- * Added Horde_Util::convertToUtf8().
+ * Added Horde_String::convertToUtf8().
  * Added Horde_Util::abbreviate().
  * Removed Horde_Array::combine() and Horde_Util::hmac().
  * Initial Horde 4 package.