parsed.org

Tips by tag: characters

Hidden Characters by xinu on Aug 27, 2007 08:18 PM

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
Lowercase Conversion by xinu on Jan 12, 2005 11:02 AM

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
Strip Non-printable Characters by xinu on Jul 03, 2005 12:44 AM

You can use PHP's trim function to remove non-printable characters:

$string = trim($string, "\x7f..\xff\x0..\x1f");
charactersfunctionslanguagesnon-printablephpprogrammingtrim
RSS