utf8_[en|de]code() requires xml extension
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Mar 2010 17:18:14 +0000 (10:18 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Mar 2010 19:09:21 +0000 (12:09 -0700)
framework/Util/lib/Horde/String.php
framework/Util/lib/Horde/Util.php
framework/Util/package.xml

index db02feb..a988135 100644 (file)
@@ -135,8 +135,10 @@ class Horde_String
         /* Use utf8_[en|de]code() if possible and if the string isn't too
          * large (less than 16 MB = 16 * 1024 * 1024 = 16777216 bytes) - these
          * functions use more memory. */
-        if ((strlen($input) < 16777216) ||
-            !(Horde_Util::extensionExists('iconv') || Horde_Util::extensionExists('mbstring'))) {
+        if (Horde_Util::extensionExists('xml') &&
+            ((strlen($input) < 16777216) ||
+             !Horde_Util::extensionExists('iconv') ||
+             !Horde_Util::extensionExists('mbstring'))) {
             if (($to == 'utf-8') &&
                 in_array($from, array('iso-8859-1', 'us-ascii'))) {
                 return utf8_encode($input);
index a36ae11..88a83e8 100644 (file)
@@ -787,7 +787,9 @@ class Horde_Util
     static public function convertToUtf8($in)
     {
         if (is_string($in)) {
-            $in = utf8_encode($in);
+            if (self::extensionExists('xml')) {
+                $in = utf8_encode($in);
+            }
         } elseif (is_array($in)) {
             reset($in);
             while (list($key, $val) = each($in)) {
index 843ec8e..f5d37e3 100644 (file)
@@ -89,6 +89,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <extension>
     <name>mbstring</name>
    </extension>
+   <extension>
+    <name>xml</name>
+   </extension>
   </optional>
  </dependencies>
  <phprelease>