来自 deflate 算法的长度值
我压缩了文本“TestingTesting”,十六进制结果为:0B 49 2D 2E C9 CC 4B 0F 81 50 00。我无法计算出长度和距离代码。下面的二进制文件是相反的,因为 RFC 说从右到左读取位(谢谢马修·斯莱特里的帮助)。以下是到目前为止解析的内容:
1 BFINAL (last block)
01 BTYPE (static)
1000 0100 132-48= 84 T
1001 0101 149-48= 101 e
1010 0011 163-48= 115 s
1010 0100 164-48= 116 t
1001 1001 153-48= 105 i
1001 1110 158-48= 110 n
1001 0111 151-48= 103 g
这些是我不知道如何解析的剩余位:
1000 0100 0000 1000 0101 0000 0000 0
最后 10 位(块结束值是 x100)是我可以解析的唯一部分。我认为长度和距离值应该是 7(二进制 0111),因为“Testing”的长度是 7 个字母,并且它会在当前位置之后复制 7 个字符,但我无法弄清楚它如何在剩余的内容中表示这一点位。我做错了什么?
I compressed the text "TestingTesting" and the hex result was: 0B 49 2D 2E C9 CC 4B 0F 81 50 00. I can't figure out the length and distance codes. The binary below is reversed because the RFC says to read the bits from right to left (thanks Matthew Slattery for the help). Here is what was parsed so far:
1 BFINAL (last block)
01 BTYPE (static)
1000 0100 132-48= 84 T
1001 0101 149-48= 101 e
1010 0011 163-48= 115 s
1010 0100 164-48= 116 t
1001 1001 153-48= 105 i
1001 1110 158-48= 110 n
1001 0111 151-48= 103 g
These are the remaining bits that I don't know how to parse:
1000 0100 0000 1000 0101 0000 0000 0
The final 10 bits (end of block value is x100) is the only part I can parse. I think the length and distance values should be 7 (binary 0111) since the length of "Testing" is 7 letters, and it gets copied 7 characters after the current position, but I can't figure out how its representing this in the remaining bits. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
距离代码是5,但是距离代码5后面跟着一个“额外位”来指示实际距离7或8。(参见第3.2.5段中的第二个表) RFC.)
数据的完整解码是:
The distance code is 5, but a distance code of 5 is followed by one "extra bit" to indicate an actual distance of either 7 or 8. (See the second table in paragraph 3.2.5 of the RFC.)
The complete decoding of the data is: