A.L.E.C wrote:

> if (function_exists('iconv') && ($result = iconv('UTF8', 'UTF8//IGNORE', 
> $input)))
>      return $result;

I've found that some iconv implementations does not support "//IGNORE". 
Also we can do this with mbstring. Here's a complete patch, please 
confirm it works (do testing also with commented out 
mb_convert_encoding's if block).

--- rcube_shared.inc    (wersja 3049)
+++ rcube_shared.inc    (kopia robocza)
@@ -599,13 +599,16 @@
      return $input;
    }

-  if (!is_string($input))
+  if (!is_string($input) || $input == '')
      return $input;

-  // iconv is 10x faster
-  if (function_exists('iconv'))
-    return iconv('UTF8', 'UTF8//IGNORE', $input);
+  // iconv/mbstring are much faster (especially with long strings)
+  if (function_exists('mb_convert_encoding') && ($res = 
mb_convert_encoding($input, 'UTF8', 'UTF8')))
+    return $res;

+  if (function_exists('iconv') && ($res = iconv('UTF8', 'UTF8//IGNORE', 
$input)))
+    return $res;
+
    $regexp = '/^('.
  //    '[\x00-\x7F]'.                                  // UTF8-1
      '|[\xC2-\xDF][\x80-\xBF]'.                      // UTF8-2


-- 
Aleksander 'A.L.E.C' Machniak http://alec.pl gg:2275252
LAN Management System Developer http://lms.org.pl
Roundcube Webmail Project Developer http://roundcube.net
_______________________________________________
List info: http://lists.roundcube.net/dev/

Reply via email to