469,917 Members | 1,783 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Distinguish between binary and text files


I need a test so I can determine whether a url points to a text file or to a
binary file. Actually, I need to distinguish between streaming files and
metafiles (e.g. asx files). I tried getmimetype, but that does not seem te
be reliab;e (dependent on the web server configuration). Can anyone help?
The test should be something like:

get url
if isbinaryfile ($url) {
do what you need to do with streaming files
} else {
do what you need to do with text files

André Rosendaal
Jul 17 '05 #1
1 2029

You could try the algorithm used by - amongst others - the diff tool:

"...diff determines whether a file is text or binary by checking the
first few bytes in the file; the exact number of bytes is system
dependent, but it is typically several thousand. If every byte in that
part of the file is non-null, diff considers the file to be text;
otherwise it considers the file to be binary."
Non-null just means any character other than ASCII 0.


Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by Eric | last post: by
12 posts views Thread by Sunner Sun | last post: by
15 posts views Thread by miki | last post: by
10 posts views Thread by joelagnel | last post: by
3 posts views Thread by nicolasg | last post: by
15 posts views Thread by JoeC | last post: by
3 posts views Thread by masood.iqbal | last post: by
9 posts views Thread by deepakvsoni | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.