====== Byte Order Mark - BOM ====== * [[http://simonstamm.de/kodierung-utf-8-ohne-bom]] * [[http://www.linuxask.com/questions/how-to-remove-bom-from-utf-8]] * [[http://stackoverflow.com/questions/1068650/using-awk-to-remove-the-byte-order-mark]] awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' text.txt > ohne_BOM.txt awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' text.txt > ohne_BOM.txt sed -i '1 s/^\xEF\xBB\xBF//' text.txt ==== PHP ==== $str = file_get_contents('utf8_with_bom.php'); $bom = pack("CCC", 0xef, 0xbb, 0xbf); if (0 == strncmp($str, $bom, 3)) { echo "BOM detected - file is UTF-8\n"; $str = substr($str, 3); }