Richard <rg****@gmail.comwrites:
"Vijay" <Vi************@gmail.comwrites:
>Hi,
Sample Hexadecimal data is given below.
Hi Vijay : go and do some reading. That is NOT hexadeciaml data
below. It is just data represented in ascii. Not the same at all.
No, it's not data represented in ASCII. It appears to be just a
binary file, neither ASCII nor hexadecimal.
To the original poster: You need to understand a few things. All
files are "binary", in the sense that they're made of bits; on most
systems you're likely to use, they're composed of 8-bit bytes. (The C
standard requires a byte to be *at least* 8 bits, but you're not
likely to run into a system with bytes larger than 8 bits unless you
work with digital signal processors, and I don't think they have file
systems.)
A given file may or may not contain some specific kind of data. If
the bytes are all ASCII characters (remember, ASCII is a 7-bit
character set), it's (presumably) an ASCII file. There are 8-bit
character sets that are extensions of ASCII. There are also character
sets not based on ASCII; EBCDIC is the most common, but you're
unlikely to run into that unless you work with IBM mainframes.
Hexadecimal is a way of representing numbers as text, using the digits
'0' to '9' and the letters 'a' to 'f' or 'A' to 'F'. You could have a
"hexadecimal file" that contains just those (ASCII) characters
(possibly with spaces and newlines added for formatting) -- but that's
not what you showed us. Hexadecimal can be a convenient way of
displaying binary data, but it's a *display* format; the binary file
is not hexadecimal.
You said you want to decode it to ASCII format. There are multitudes
of ways you could do that, generating a sequence of ASCII characters
that specify the content of the binary file. (The ASCII
representation is likely to be larger than the original binary file;
if you represent it as hexadecimal digits, it will be twice the size,
one 8-bit character for each 4-digit hexadecimal digit.)
I could guess what you're trying to do, but I'm not going to. You
need to define the problem. You have a binary file as input (BTW,
please don't post binary files here), and you want some kind of ASCII
output, but you haven't said *how* the ASCII should correspond to the
binary data.
But even if you define the problem, you may still be asking in the
wrong place. You mention that you want to do this in C, but you
haven't shown any indication that you've tried to do it yourself.
First you need to define the problem. Then you need to make some
effort to solve it yourself. If you have some partially working code
and you can't figure out why it's not working, post it here and we can
offer advice. We won't do it for you.
Unless, of course, this is a homework assignment; in that case, just
give us your instructor's e-mail address so we can submit our
solutions directly. It's up to you whether we mention your name or
not.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.