Permalink
Browse files

MDL-36245 try to workaround buggy iconv() when converting text from u…

…tf-8 to utf-8
  • Loading branch information...
1 parent a7cc54a commit 30075232afdf2474b871e7e6c0f238979ffad09b @skodak skodak committed with stronk7 Nov 8, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/textlib.class.php
View
@@ -151,8 +151,7 @@ public static function parse_charset($charset) {
/**
* 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
@@ -169,6 +168,10 @@ public static function convert($text, $fromCS, $toCS='utf-8') {
return '';
}
+ if ($toCS === 'utf-8' and $fromCS === 'utf-8') {
+ return fix_utf8($text);
+ }
+
$result = iconv($fromCS, $toCS.'//TRANSLIT', $text);
if ($result === false or $result === '') {

0 comments on commit 3007523

Please sign in to comment.