Re: Ascii or Binary File??

From: willem van Deursen (noname_at_noname.nl)
Date: 09/10/04


Date: Fri, 10 Sep 2004 18:53:10 +0200

You should check the file for any character that is not in the range
'A'..'Z','a'..'z','0'..'9' and all the special characters that you would
allow (such as ':',';','<') and so on. If you encounter one character
thats not allowed, then its binary. However, even if you encounter only
allowed characters, theres no way to be absolutely sure whether the file
should not be interpreted as binary

'AwwQ!!33234##' might be interpreted as all valid text characters, but
it is likely to be a binary file, so no guaranteed result...

Willem van Deursen

Leonel wrote:

> Nick Rollas wrote:
>
>
>>Is it possible to know if a file is Ascii or Bin? I'm writting an FTP
>>Client and i want to determinate whether the file is binary or text.
>
>
> A comment I just copied from Abbrevia source code:
>
> the test for whether a stream is binary or not is to
> check whether there are any #0 characters in the first
> 1024 bytes: if there are the stream is binary.
>
> To know for sure, you'd have to read the whole file. To guess, you
> might try a similar way as described above.
>

-- 
Willem van Deursen, The Netherlands
wvandeursen_nospam@nospam_carthago.nl
replace _nospam@nospam_ for @ to get a valid email address
www.carthago.nl


Relevant Pages

  • Re: help interpreting Gleemax posts
    ... I find that to be a poor metric, because party composition makes a big ... characters come in and out, including a super-righteous Monk, and a highly ... beating the encounter, the odds of a character death, the odds of a TPK) ... I guess my point was that using the corresponding metrics from the 2 ...
    (rec.games.frp.dnd)
  • Re: realloc(): invalid next size
    ... What happens if you encounter a token larger than 50 characters? ... If the above is your exact code, ... it doesn't compile, because there is a lot missing. ...
    (comp.lang.c)
  • Re: The 4e rules as a wargame
    ... "Monsters that are ... Since hazards are equivalent to monsters for encounter ... would almost certainly kill a wizard of the appropriate level. ... and you compare them to the characters' level to judge whether ...
    (rec.games.frp.dnd)
  • Re: a few more questions (3.5E)
    ... I thought the encounter was 50/50, and I think they only lost a couple ... of characters because they made a few mistakes. ... Anyway, the DMG says first of all find the average party level, but ... Clearly 8x3rd level characters is a more powerful force than 4x3rd ...
    (rec.games.frp.dnd)
  • Re: Fiendish Codex: Any good?
    ... I don't know enough about the epic rules to judge them good or bad, ... levels (and the equivalent creatures likewise: ... encounter of that Encounter Level. ... monsters (and thus characters) scale in power. ...
    (rec.games.frp.dnd)