In article <11**********************@b75g2000hsg.googlegroups .com>,
bwv539 <bw****@yahoo.comwrote:
>That is, I need something like a header in the file to interpret it. I
thought to use ascii header, but I do not want to mix ascii and bin in
the file.
What could be a simple solution?
ASCII is just a particular interpretation of 8 bit binary characters.
As far as binary file theory is concerned, there is no difference
(other than efficiency) between having a binary string
\x54\x59\x50\x45\x33\x42 or a binary string \x3B .
The first of the two happens to be interpretable in ASCII as
'TYPE3B', but really it's just a binary string of no more
(and no less) meaning to the file than the binary string \x3B.
The time to be concerned about ASCII vs binary (more correctly, text
streams vs binary streams) is in the treatment of line terminators
(e.g., \n ) and the treatment of binary 0's. If you were trying to mix
binary and text on the same logical line and read it back in a text
stream, you would need to be concerned in case the binary happened to
come out as binary 0 or happened to come out as one of the
implementation-dependant line terminators. But if you are consistant
in using binary streams, and wish to write out something that
is readable to humans when viewed as ASCII, you just have to worry
about whether the execution character set is ASCII
(because if it isn't, and you fputs("TYPE3B",stdout) then
it might not be ASCII's "T" and "Y" and so on that were written out.)
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson