summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-10-22 18:37:00 +0000
committeralecpl <alec@alec.pl>2009-10-22 18:37:00 +0000
commitb6c512a6b0420d5b83e05282c8d0251d47742fae (patch)
tree1a37732d3b3bc073d42ee190ef0ce0776f3b35d0 /program
parentee51070c462f5701dc9562fa1453ac6da825b1c2 (diff)
- fix rc_utf8_clean() on Windows (#1486232)
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_shared.inc11
1 files changed, 7 insertions, 4 deletions
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index d60291012..97314ccd1 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -599,12 +599,15 @@ function rc_utf8_clean($input)
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