如何在golang中使用zlib与c中的zlib合作? [英] How can I use zlib in golang to cooperate with zlib in c?

查看:137
本文介绍了如何在golang中使用zlib与c中的zlib合作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,对于相同的字符串,在golang中使用zlib的结果与c中的结果不同。如何通过zlib在golang中压缩和在c中解压缩?会使用哪个版本?

I found that, for the same string, the result of using zlib in golang is different with that in c. How can I compress in golang and decompress in c by zlib ? Which version does go use?

推荐答案

仅仅是因为压缩数据不同,并不意味着它不能被解压缩。可以在其他任何地方使用兼容的zlib解码器对在任何地方生成的与zlib兼容的压缩数据进行解压缩。您是否尝试过解压缩?

Just because the compressed data is different doesn't mean that it can't be decompressed. zlib-compliant compressed data generated anywhere can be decompressed by a compliant zlib decoder anywhere else. Did you try decompressing?

至于区别,@ twotwotwo指出Go中的compress / zlib不是原始zlib库的 ,而是而不是用Go编写的不同实现。因此,如果它使用不同的算法来查找匹配项和/或发出块,则会产生不同的输出。

As for the difference, @twotwotwo points out that compress/zlib in Go is not the original zlib library, but rather a different implementation written in Go. So it would be expected to generate different output if it uses different algorithms to find matches and/or emit blocks.

这篇关于如何在golang中使用zlib与c中的zlib合作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆