>I don't know of any quick and dirty way to tell a binary from a text file. As you know, DOS/Windows files aren't coded by file type.
>
>I'm assuming your're not talking about Unicode files but "normal" ASCII files containing one byte per character.
>
>However, I guess it depends on your definition of binary file. If you accept my definition then here's a chunk of code that will work fairly well but may be a little slow on large files. Of course, it's easily modifiable.
>
>* IsBinary() - Return .T. if the passed file contents is binary
>FUNCTION IsBinary( cContents )
> LOCAL nX, cChar
>
> * A binary file is one that contains characters from CHR(127)-7Fh or
> * higher. But, some languages use characters from CHR(128)-80h thru
> * CHR(168)-0A9h so we'll ignore those.
>
> * Look for each of these characters in the file's contents
> FOR nX = 127 TO 255
> IF nX = 128
> nX = 168
> LOOP
> ENDIF
> cChar = CHR(nX)
> IF cChar $ cContents
> RETURN .T.
> ENDIF
> ENDFOR
> RETURN .F.
>ENDFUNC
I think a more general approach would be to search for the occurance of a CHR(0) or CHR(26) other than at or beyond EOF() - those two are deinite no-nos for text files, while screen dumps of DOS boxes with line drawing characters might contain high ASCII.