Algorithm for File IO
Hello All
Can any one inform me on how to find out if a binary file is a text file or a try binary. There is a class that reads all files as binary (both text and binary). I need to be able to distinguish at run-time whether the file is text (i.e. .txt, .rtf, .sql files are considered text) and binary
Thanks
[328 byte] By [
janisofta] at [2007-10-1 21:56:54]

You can have some heuristics, both on octet value distribution and also some unicode byte-order marks (see the XML spec for some algorithms for guessing different text encodings). For RTF and SQL you also have definite grammars they must obey. But you won't ever get a 100% accurate test.
Pete