From: Michael M Slusarz Date: Wed, 10 Mar 2010 01:33:26 +0000 (-0700) Subject: Move convertToUtf8() from Horde_Util:: to Horde_String:: X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=08a153b38c7c4edbd7e910c3fe98f720e2a0eb72;p=horde.git Move convertToUtf8() from Horde_Util:: to Horde_String:: --- diff --git a/framework/Serialize/lib/Horde/Serialize.php b/framework/Serialize/lib/Horde/Serialize.php index b5cd84e32..be7a40ae5 100644 --- a/framework/Serialize/lib/Horde/Serialize.php +++ b/framework/Serialize/lib/Horde/Serialize.php @@ -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; } diff --git a/framework/Util/lib/Horde/String.php b/framework/Util/lib/Horde/String.php index a98813525..e926fc30a 100644 --- a/framework/Util/lib/Horde/String.php +++ b/framework/Util/lib/Horde/String.php @@ -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; + } + } diff --git a/framework/Util/lib/Horde/Util.php b/framework/Util/lib/Horde/Util.php index cccea4439..2dca95aa8 100644 --- a/framework/Util/lib/Horde/Util.php +++ b/framework/Util/lib/Horde/Util.php @@ -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; - } - } diff --git a/framework/Util/package.xml b/framework/Util/package.xml index f5d37e3f4..a7aefb8f7 100644 --- a/framework/Util/package.xml +++ b/framework/Util/package.xml @@ -32,7 +32,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> * 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.