Zap the Gremlins
Invisible characters, sometimes referred to as gremlins, interspersed in text files, can nevertheless become visible as strange characters when displayed in a browser. Further, if the file is used as a template where certain sequences of characters need to be replaced, gremlins within the sequence can abort the replacement.
Here is a Perl CGI script that may be used to strip out unwanted invisible whitespace characters.
#!/usr/bin/perl use strict; my $inFileName = 'file.txt'; my $outFileName = 'newfile.txt'; local $/; open R,"<$inFileName"; binmode R; open W,">$outFileName"; for(split //,<R>) { print W if /[\n\r\t]/ or (ord($_) >= 32 and ord($_) < 127); } print "Content-type: text/html\n\ndone";
In the script, specify the file to read in and the file to write out. Make these different file names. The "out" file will overwrite anything with the same name, so choose the file name carefully.
Return and linefeed characters will be retained, as will tab and regular space characters. All other whitespace characters are removed.
Note:
If you don't already know how to install a CGI script, here are the basic CGI script installation instructions that apply to all of them.
Will Bontrager