mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-9075 utf-8 bom is now stripped from uploaded users cvs file; merged from MOODLE_18_STABLE
This commit is contained in:
parent
413efd2200
commit
77b4d4be49
@ -67,8 +67,11 @@ if ($um->preprocess_files() && confirm_sesskey()) {
|
||||
@apache_child_terminate();
|
||||
}
|
||||
|
||||
//Fix mac/dos newlines
|
||||
$text = my_file_get_contents($filename);
|
||||
//trim utf-8 bom
|
||||
$textlib = new textlib();
|
||||
$text = $textlib->trim_utf8_bom($text);
|
||||
//Fix mac/dos newlines
|
||||
$text = preg_replace('!\r\n?!',"\n",$text);
|
||||
$fp = fopen($filename, "w");
|
||||
fwrite($fp,$text);
|
||||
|
@ -322,5 +322,15 @@ class textlib {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the BOM from unicode string - see http://unicode.org/faq/utf_bom.html
|
||||
*/
|
||||
function trim_utf8_bom($str) {
|
||||
$bom = "\xef\xbb\xbf";
|
||||
if (strpos($str, $bom) === 0) {
|
||||
return substr($str, strlen($bom));
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user