Re: detecting file types
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Wed, 08 Feb 2006 21:50:26 -0000
On 2006-02-08, Joe Pfeiffer <pfeiffer@xxxxxxxxxxx> wrote:
I read it quickly, but in fact this was not what I was looking
for. I needed a way to detect, in a program made in C/C++, if
a file is a binary one or a simple ascii one.
There is no quick and reliable way to do it. All you can really do is
scan the file looking for non-printing characters, and if you find
enough of them decide it's not ASCII (do you really mean ASCII, by the
way, or an eight-bit extension like ISO-8859-1?);
If he wants to allow something like ISO-8859-1, then he's going
to need to build a table containing the file's byte
distribution frequencies and do a "fuzzy" compare to the
distributions of known language/charset pairs. Not a
particularly easy/simple thing to do.
or, you can use the "system" call from inside your program to
execute file.
Or he can trust that the user knows what he's doing and just
process the file he's been told to. ;)
--
Grant Edwards grante Yow! Four thousand
at different MAGNATES, MOGULS
visi.com & NABOBS are romping in my
gothic solarium!!
.
- Follow-Ups:
- Re: detecting file types
- From: Joe Pfeiffer
- Re: detecting file types
- References:
- detecting file types
- From: dagecko
- Re: detecting file types
- From: Bill Marcum
- Re: detecting file types
- From: dagecko
- Re: detecting file types
- From: Chris F.A. Johnson
- Re: detecting file types
- From: dagecko
- Re: detecting file types
- From: Joe Pfeiffer
- detecting file types
- Prev by Date: Re: detecting file types
- Next by Date: Re: Help a newbie :) (prob with 'for')
- Previous by thread: Re: detecting file types
- Next by thread: Re: detecting file types
- Index(es):
Relevant Pages
|