How to find out if a file contains binary or ascii data?

Just starting out? Need help? Post your questions and find answers here.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

How to find out if a file contains binary or ascii data?

Post by Kale »

How do i go about finding out if a file contains binary or ascii data? i.e. is there a way to find out if a file is a binary other than the extension?
--Kale

Image
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: How to find out if a file contains binary or ascii data?

Post by GPI »

Kale wrote:How do i go about finding out if a file contains binary or ascii data? i.e. is there a way to find out if a file is a binary other than the extension?
There is no way, because a ASCII-File IS a binary file and has no header.
All Files are Binary-Files, but some has headers, for example EXE,BMP,etc. other has none.

When i know it right, on linux has all files a header, but not on windows.

The only thing, that you can do:
Test the File ever byte. When you found values 1 - 9, 11-12, 14-31,127 it is normaly no ascii-file, because this are specail ASCII-Values for specaial thing (backspace, eof,etc)

GPI
Post Reply