Re: How to distinguish between binary and ASCII file on file opening?
From: Bill Thompson (billt61_at_rgv.rr.com)
Date: 08/15/04
- Next message: Joseph M. Newcomer: "Re: DLL Question"
- Previous message: Joseph M. Newcomer: "Re: CArray Pointer Argument"
- In reply to: CFF: "How to distinguish between binary and ASCII file on file opening?"
- Next in thread: Joseph M. Newcomer: "Re: How to distinguish between binary and ASCII file on file opening?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 15 Aug 2004 01:05:08 -0500
"CFF" <cffung@myrealbox.com> wrote in message
news:2560187f.0408091926.16ca0e19@posting.google.com...
> I am writing an applicatioin that will need to distinguish between
> binary and ASCII file to be loaded from hard disk so that different
> processing is applied to different type of file.
>
> Is there any simple way to identify the type of file during the file
> opening process? Thank you.
>
> CFF
You could analyze character frequency. If the predominate characters are
A-Za-z you probably have ASCII, if the distribution is more uniform you
probably have binary. The more characters you check, the stronger the
'probably' becomes.
Any clues about the contents of the file can be useful as well; e.g., you
can recognize a CSV file by the number of unqouted commas per line.
- Next message: Joseph M. Newcomer: "Re: DLL Question"
- Previous message: Joseph M. Newcomer: "Re: CArray Pointer Argument"
- In reply to: CFF: "How to distinguish between binary and ASCII file on file opening?"
- Next in thread: Joseph M. Newcomer: "Re: How to distinguish between binary and ASCII file on file opening?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|