If you need to know where a line ends, where unprintable characters lurk, and the difference between white space and tabs, you can always remember to take the cat to the vet:
$ <commands> | cat -vet
catcharacterscommandscrlfshell
If you find yourself needing to drop the case on the entire contents of a file, you can try this:
$ dd if=original of=filtered conv=lcase -or- $ tr '[A-Z]' '[a-z]' < original > filtered
charactersconversionddfilterlowercaseshelltr
You can use tr to remove non-printable characters from a data stream:
$ tr -cd '\11\12\40-\176' < $INPUT_FILE > $OUTPUT_FILE
(This tip taken from http://www.devdaily.com/unix/edu/un010011/.)
charactersconvertfilternon-printableshelltr
You can use PHP's trim function to remove non-printable characters:
$string = trim($string, "\x7f..\xff\x0..\x1f");
charactersfunctionslanguagesnon-printablephpprogrammingtrim