TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Decompressing a Gzip File by Hand

145 点作者 thomastay超过 3 年前

5 条评论

Rendello超过 3 年前
For anyone looking to write their own Deflate&#x2F;Gzip&#x2F;Zlib, I would recommend looking at the little program called `infgen`:<p>&gt; infgen is a deflate stream disassembler. It will read a gzip, zlib, or raw deflate stream, and output a readable description of the contents.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;madler&#x2F;infgen" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;madler&#x2F;infgen</a>
评论 #29338181 未加载
评论 #29338160 未加载
评论 #29339654 未加载
评论 #29340154 未加载
userbinator超过 3 年前
One of the mantras I used when I was a programming instructor was &quot;How can you know what to tell the computer to do, if you can&#x27;t do it yourself?&quot; This is a great example of that.<p><i>Don’t forget that the huffman codes are packed LSB to MSB, but are to be interpreted as an integer in big endian format. Why this insanity?</i><p>Because that&#x27;s what Phil Katz did. I vaguely remember reading about that years ago, and believe it had to do with how he implemented it; not as canonical table lookup, but as explicit tree-walking, since the former hadn&#x27;t really been invented yet and the latter would fit within the memory constraints of a 16-bit system (DOS on a PC).
评论 #29338726 未加载
bloak超过 3 年前
And here&#x27;s a gzip quine for anyone who likes that sort of thing:<p><pre><code> ( echo H4sIAAAAAAAAA5Pv5mCIeLzKnIGZgYHh&#x2F;38GEYbX&#x2F;+WxiDl1 ; echo KB5hIIJ1TXfrBNeU3DznNGYG78SS1AKgEchsAEthdGVwAAAA ) | base64 -d | gunzip &gt; quine.gz zcat quine.gz | diff - quine.gz</code></pre>
评论 #29340938 未加载
ryan-duve超过 3 年前
This was a great read. I look forward to the Part II teased at the end. In addition to deep diving on the Huffman codes, I hope you find a way to include an explanation of when to read left-to-right vs right-to-left, which is what tripped me up the most in this article.
评论 #29337042 未加载
oldpatricka超过 3 年前
I love this! Great post.