From f16a1438723fff98c6918d9efeb60f39cd47ca10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Thu, 8 Nov 2012 08:49:50 +0100 Subject: [PATCH] MDL-36245 try to workaround buggy iconv() when converting text from utf-8 to utf-8 --- lib/textlib.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/textlib.class.php b/lib/textlib.class.php index 77fafc1278e..ab0db3c4780 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -161,8 +161,7 @@ class textlib { /** * Converts the text between different encodings. It uses iconv extension with //TRANSLIT parameter, - * falls back to typo3. - * Returns false if fails. + * falls back to typo3. If both source and target are utf-8 it tries to fix invalid characters only. * * @param string $text * @param string $fromCS source encoding @@ -179,6 +178,10 @@ class textlib { return ''; } + if ($toCS === 'utf-8' and $fromCS === 'utf-8') { + return fix_utf8($text); + } + $result = iconv($fromCS, $toCS.'//TRANSLIT', $text); if ($result === false or $result === '') {