MDL-9075 utf-8 bom is now stripped from uploaded users cvs file

This commit is contained in:
skodak
2007-04-10 15:30:51 +00:00
parent 7ec5b06656
commit 6b68f4e53b
2 changed files with 14 additions and 1 deletions
+4 -1
View File
@@ -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);
+10
View File
@@ -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;
}
}
?>