Subject: Re: Testing for binary file From: Erik Naggum <firstname.lastname@example.org> Date: Tue, 05 Mar 2002 01:10:48 GMT Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * Brian Seitz <firstname.lastname@example.org> | Is there a standard way to test a file for being binary or | text? Something to the effect of -B in Perl. I would be using either | Allegro 5.01 or CMUCL (whatever version is in Debian unstable). I have no idea what -B does in Perl, but a text file is generally understood to be a file that lacks any other control characters than the horizontal (CR, HT, SP) and vertical (LF, VT) format effectors. If you have a decently encoded character set, that means very few characters in the ranges #x00-#x1f and #x7f-#x9f. If you have some IBM-based crud page or any one of the usual Microsoft disasters, there is no way to tell for real, except you would probably find periodic line breaks with CRLF in text files. A common and very simple negative test for a text file is if the last character in teh file is not a line feed. /// -- In a fight against something, the fight has value, victory has none. In a fight for something, the fight is a loss, victory merely relief.