UTF8 BOM should be replaced with a PHP_EOL

This commit is contained in:
Matt Pass
2016-04-26 09:15:55 +01:00
parent eabae9bed4
commit 6735caae36

View File

@@ -133,8 +133,9 @@ function toUTF8noBOM($string,$message) {
// Attempt to detect encoding
if (function_exists('mb_detect_encoding')) {
$strictUTF8 = mb_detect_encoding($string, 'UTF-8', true);
// Get rid of any UTF-8 BOM
$string = preg_replace('/\x{EF}\x{BB}\x{BF}/','',$string);
// Get rid of any UTF-8 BOM, need to replace with a line return
$string = preg_replace("/\x{EF}\x{BB}\x{BF}/",PHP_EOL,$string);
// Test for any bad characters
$teststring = $string;
$teststringBroken = utf8_decode($teststring);