* 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;
}
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;
+ }
+
}
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;
- }
-
}
<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.