delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
From: | "jansb000" <jansb000 AT planet DOT nl> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: how to determine if a file is text/binary |
Date: | Wed, 1 May 2002 21:45:36 +0200 |
Organization: | Planet Internet |
Lines: | 23 |
Message-ID: | <aapgkv$im1$1@reader05.wxs.nl> |
References: | <Pine DOT SUN DOT 3 DOT 91 DOT 1020430081409 DOT 3296J-100000 AT is> <c21a43ff DOT 0204302309 DOT 7c13ed96 AT posting DOT google DOT com> |
NNTP-Posting-Host: | ipc3797b4e.dial.wxs.nl |
X-Trace: | reader05.wxs.nl 1020282335 19137 195.121.123.78 (1 May 2002 19:45:35 GMT) |
X-Complaints-To: | abuse AT planet DOT nl |
NNTP-Posting-Date: | 1 May 2002 19:45:35 GMT |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 6.00.2600.0000 |
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2600.0000 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
If all data that you read is between Hex 20 and Hex 7F (with exception for Hex 0D or Hex 0D 0A) then there is a good chance the file is ASCII. To be more sure: Test if you can detect sentences in the form: ASCII_FILE = ASCII_SEQUENCE + TERMINATOR ASCII_SEQUENCE = ASCII2_SEQUENCE + LINE_BREAK ASCII2_SEQUENCE = ASCII* [+ SPACE* + ASCII*]* ASCII = 'A', 'B', 'C', etc ... SPACE = ' ', '\t', etc ... "xeon" <xeon AT dacreations DOT cjb DOT net> schreef in bericht news:c21a43ff DOT 0204302309 DOT 7c13ed96 AT posting DOT google DOT com... > Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote in message news:<Pine DOT SUN DOT 3 DOT 91 DOT 1020430081409 DOT 3296J-100000 AT is>... > > The usual technique is to read a portion of a file, say, 16KB, and see if > > it contains null characters (`\0'). > Is there any other way? Test reading Kb's of data may not be an option > in this particular project. > > TIA
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |