Saturday, May 23, 2009

does your file have control-m's in it?

* cat -v filename

or use the following php code:

if ($argc != 2) {
print "Wrong Usage\n";
exit (1);
}

$filename= $argv[1];

$handle = @fopen($filename, "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
if (preg_match_all('|^(.*)\cM$|',$buffer,$matches,PREG_PATTERN_ORDER)) {
print "Found control M in $filename\n";
exit;
}
}
fclose($handle);
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home