Article View: borland.public.cppbuilder.nativeapi
Article #16625Re: Ascii or binary file
From: Jim Dodd
Date: Fri, 09 May 2003 16:44
Date: Fri, 09 May 2003 16:44
34 lines
2342 bytes
2342 bytes
Andrue Cope wrote: > Jim Dodd, > > >>In this way, we don't use Andrue's "times 3" fudge factor. We just say >>that if ANY character falls out side the range [8,9,10,13,26,32-127], >>the file is probably a binary file. >> > > > 'Fudge factor'? How dare you sir. It's a kludge :) > > In truth our routine is son-of-son-of-something-written-many-years-ago > and hence my disclaimer about statistics. It's a definite example of code > that has evolved to meet requirements. We don't claim to know why it's so > good we just accept that it is <g,d&r>. > > Another reason why I've never tried to rationalise it is that it counts > lines and generates an index for fast seeking. It handles various methods > of EOL marking (CR/LF, LF/CR, CR, LF) and I don't want to touch that code > with a bargepole :) > > Andrue Cope > [Bicester, UK] > Very good :-) Actually, I employ my own "factor" which I was reminded of when reading Gambit's later reply - I don't usually read the entire file. I pick a percentage of the file size and read that (usually 10-20%) and if I haven't found any non-text characters by that time, I declare it text. Jim Dodd Onset Computer Corp.
Technical Details
Message-ID:
<3ebbdade$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3eba4f4a@newsgroups.borland.com> <VA.00001c9d.01332329@email.address.sorry> <3eba6b37$1@newsgroups.borland.com> <VA.00001c9e.01a5e272@email.address.sorry>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,65ce5fe967ca5eb X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-09 09:53:30 PST Date: Fri, 09 May 2003 12:44:16 -0400 From: Jim Dodd <bcbuilderboy@yahoo.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Ascii or binary file References: <3eba4f4a@newsgroups.borland.com> <VA.00001c9d.01332329@email.address.sorry> <3eba6b37$1@newsgroups.borland.com> <VA.00001c9e.01a5e272@email.address.sorry> In-Reply-To: <VA.00001c9e.01a5e272@email.address.sorry> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 65.161.163.42 Message-ID: <3ebbdade$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1052498654 65.161.163.42 (9 May 2003 09:44:14 -0700) Lines: 35 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail