Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compression > #1962
| From | Christoph-Simon Senjak <css@uxul.de> |
|---|---|
| Newsgroups | comp.compression |
| Subject | Beginner's question about RFC 1951 |
| Date | 2013-05-31 15:25 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <koa84l$ia$1@dont-email.me> (permalink) |
Hello.
I am currently trying to understand RFC 1951. I used the example file
http://zlib.net/zpipe.c to generate a Deflate stream. I use the
following program to dump the binary representation of the created
deflate stream:
/* toBin.c */
#include <stdio.h>
void toString (int c, char* out) {
int i;
for (i = 0; i < 8; ++i) {
out[i] = ((c >> i) % 2) == 0 ? '0' : '1';
}
}
int main (void) {
int c;
char ts[9]; ts[8] = 0;
while ((c = getchar()) != EOF) {
toString(c, ts);
printf("%s.", ts);
}
}
Now, when running
$ echo "Hello World" | ./zpipe | ./toBin
I get a String starting with
00011110.00111001.11001111.00010010.10110011.
If I understand correctly, the leading bits 000 means "not the last
block" and "no compression", according to RFC 1951. The next five bits
are ignored, and then two times sixteen bits are used to indicate the
length of the uncompressed block, and the should be the complement of
each other, but as you can see, they are not.
I thought of maybe interpreting the bit-endianness wrong, but even if I
reverse the first byte, it starts with 011, and the compression method
11 is reserved, according to RFC 1951.
What am I missing? Sorry if this is a stupid question, but I am trying
to understand the RFC, and I am not yet familiar with everything.
Best Regards,
Christoph-Simon Senjak
Back to comp.compression | Previous | Next — Next in thread | Find similar | Unroll thread
Beginner's question about RFC 1951 Christoph-Simon Senjak <css@uxul.de> - 2013-05-31 15:25 +0200
Re: Beginner's question about RFC 1951 Ian Clifton <ian.clifton@chem.ox.ac.uk> - 2013-05-31 15:33 +0100
Re: Beginner's question about RFC 1951 Christoph-Simon Senjak <css@uxul.de> - 2013-05-31 17:35 +0200
Re: Beginner's question about RFC 1951 Christoph-Simon Senjak <css@uxul.de> - 2013-05-31 23:36 +0200
csiph-web