MDL-41197 normalize ascii text conversion

This commit is contained in:
Petr Škoda
2013-10-08 00:00:21 +02:00
committed by Eloy Lafuente (stronk7)
parent 06db3cf3cc
commit 896a790f69
2 changed files with 11 additions and 2 deletions
+6 -2
View File
@@ -93,8 +93,12 @@ class core_textlib_testcase extends advanced_testcase {
$this->assertSame(textlib::convert($utf8, 'utf-8', 'utf-8'), $utf8);
$utf8 = "Žluťoučký koníček";
$this->assertSame('Zlutouck\'y kon\'icek', core_text::convert($utf8, 'utf-8', 'ascii'));
$this->assertSame($utf8, core_text::convert($utf8.chr(130), 'utf-8', 'utf-8'));
$this->assertSame('Zlutoucky konicek', textlib::convert($utf8, 'utf-8', 'ascii'));
$this->assertSame($utf8, textlib::convert($utf8.chr(130), 'utf-8', 'utf-8'));
$utf8 = "Der eine stößt den Speer zum Mann";
$this->assertSame('Der eine stoesst den Speer zum Mann', textlib::convert($utf8, 'utf-8', 'ascii'));
$iso1 = textlib::convert($utf8, 'utf-8', 'iso-8859-1');
$this->assertSame('Der eine stoesst den Speer zum Mann', textlib::convert($iso1, 'iso-8859-1', 'ascii'));
}
/**
+5
View File
@@ -185,6 +185,11 @@ class textlib {
}
}
if ($toCS === 'ascii') {
// Try to normalize the conversion a bit.
$text = self::specialtoascii($text, $fromCS);
}
// Prevent any error notices, do not use //IGNORE so that we get
// consistent result from Typo3 if iconv fails.
$result = @iconv($fromCS, $toCS.'//TRANSLIT', $text);