From ... Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!newsfeeds.belnet.be!news.belnet.be!news2.kpn.net!news.kpn.net!nslave.kpnqwest.net!nloc2.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader3.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Testing for binary file References: Mail-Copies-To: never From: Erik Naggum Message-ID: <3224279457059736@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 22 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 05 Mar 2002 01:10:48 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader3.kpnqwest.net 1015290648 193.71.199.50 (Tue, 05 Mar 2002 02:10:48 MET) NNTP-Posting-Date: Tue, 05 Mar 2002 02:10:48 MET Xref: archiver1.google.com comp.lang.lisp:27793 * Brian Seitz | 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.