delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/29/16:32:23

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: xeon AT dacreations DOT cjb DOT net (xeon)
Newsgroups: comp.os.msdos.djgpp
Subject: how to determine if a file is text/binary
Date: 29 Apr 2002 13:16:17 -0700
Organization: http://groups.google.com/
Lines: 10
Message-ID: <c21a43ff.0204291216.53eaf67c@posting.google.com>
NNTP-Posting-Host: 202.137.18.31
X-Trace: posting.google.com 1020111378 11694 127.0.0.1 (29 Apr 2002 20:16:18 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: 29 Apr 2002 20:16:18 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

I'm wondering, how to determine is a file is a text file, or a binary
file, programatically. I'm thinking about reading 4 bytes from the
file and test them if they're in the range of usual text ([a-z],
[A-Z], etc. The 4 bytes is read from the following locations : 1st
byte, last byte, and 2 randomly selected offset inside the file. Is
this enough?

TIA

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019