mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'w41_MDL-41197_m26_convnotices' of https://github.com/skodak/moodle
This commit is contained in:
commit
4c9da232d0
2 changed files with 12 additions and 3 deletions
|
@ -178,11 +178,16 @@ class core_text {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($toCS === 'utf-8' and $fromCS === 'utf-8') {
|
if ($fromCS === 'utf-8') {
|
||||||
return fix_utf8($text);
|
$text = fix_utf8($text);
|
||||||
|
if ($toCS === 'utf-8') {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = iconv($fromCS, $toCS.'//TRANSLIT', $text);
|
// 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);
|
||||||
|
|
||||||
if ($result === false or $result === '') {
|
if ($result === false or $result === '') {
|
||||||
// note: iconv is prone to return empty string when invalid char encountered, or false if encoding unsupported
|
// note: iconv is prone to return empty string when invalid char encountered, or false if encoding unsupported
|
||||||
|
|
|
@ -88,6 +88,10 @@ class core_text_testcase extends advanced_testcase {
|
||||||
$this->assertSame($str, core_text::convert($utf8, 'utf-8', 'GB18030'));
|
$this->assertSame($str, core_text::convert($utf8, 'utf-8', 'GB18030'));
|
||||||
$this->assertSame($utf8, core_text::convert($str, 'GB18030', 'utf-8'));
|
$this->assertSame($utf8, core_text::convert($str, 'GB18030', 'utf-8'));
|
||||||
$this->assertSame($utf8, core_text::convert($utf8, 'utf-8', 'utf-8'));
|
$this->assertSame($utf8, core_text::convert($utf8, 'utf-8', 'utf-8'));
|
||||||
|
|
||||||
|
$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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue