Scott Stafford was nice enough to post code for asc-gzip/.xfd decompression to go with my asc-gzip/.xfd compression code. See this comment. I’m also reposting it here because the comment formatting is a little more bad than the main-post formatting.
Thanks for your post. Of course, I needed the opposite, I had one I needed to decompress. So I backwarded your algorithm and here is the result:
def decompress(fc): fc2 = fc.splitlines(True) fc3 = "".join(fc2[1:]) # could verify that it's asc-gzip here if we wanted to... unb64 = base64.standard_b64decode(fc3) ctr = 0 ret = [] while 1: if ctr == len(unb64): break ccltop = ord(unb64[ctr]) ctr += 1 cclbottom = ord(unb64[ctr]) ctr += 1 compressedchunklen = ccltop * 256 + cclbottom cltop = ord(unb64[ctr]) ctr += 1 clbottom = ord(unb64[ctr]) ctr += 1 chunklen = cltop * 256 + clbottom #~ print compressedchunklen, chunklen compressedchunk = unb64[ctr:ctr+compressedchunklen] ctr += compressedchunklen chunk = zlib.decompress(compressedchunk) assert(len(chunk) == chunklen) ret.append(chunk) return "".join(ret)