mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-32586 silence buggy glibc when fixing utf-8 strings
This commit is contained in:
parent
aa753ac24f
commit
51b7297b7e
1 changed files with 10 additions and 1 deletions
|
@ -1127,7 +1127,16 @@ function fix_utf8($value) {
|
|||
// shortcut
|
||||
return $value;
|
||||
}
|
||||
return iconv('UTF-8', 'UTF-8//IGNORE', $value);
|
||||
// lower error reporting because glibc throws bogus notices
|
||||
$olderror = error_reporting();
|
||||
if ($olderror & E_NOTICE) {
|
||||
error_reporting($olderror ^ E_NOTICE);
|
||||
}
|
||||
$result = iconv('UTF-8', 'UTF-8//IGNORE', $value);
|
||||
if ($olderror & E_NOTICE) {
|
||||
error_reporting($olderror);
|
||||
}
|
||||
return $result;
|
||||
|
||||
} else if (is_array($value)) {
|
||||
foreach ($value as $k=>$v) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue