Snippets

Daniel Sasser PHP Detect Byte order mark (BOM) 

Created by Daniel Sasser
1
2
3
4
5
6
$str = file_get_contents('yourfile.utf8.csv');
$bom = pack("CCC", 0xef, 0xbb, 0xbf);
if (0 === strncmp($str, $bom, 3)) {
    echo "BOM detected - file is UTF-8\n";
    $str = substr($str, 3);
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.