We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
有很多 zlib 文章、技巧和教程。其中一些是
1) Bobobobo 的博客
本文主要告诉您如何使用 zlib,并且有一段代码可以帮助您入门。
2) zlib:将工业强度压缩添加到您的 C/C++ 应用程序
由于它是C语言的,因此它将最有利于您的要求。
最后,您也可以在 zlib 中使用它。来自手册,实用函数:
Well there are many zlib articles , tips and tutorials. Some of them are
1) Bobobobo's Blog
This article basically tells you how to use zlib, and there is a snippet of code that will get you going.
2) zlib: Add Industrial Strength Compression to Your C/C++ Apps
Since its in C language, it will be most beneficial to your requirements.
Last, you can use this too available in zlib. From the manual, Utility Functions:
请参阅http://zlib.net/zlib_how.html
See http://zlib.net/zlib_how.html
http://www.boost.org/doc /libs/1_48_0/libs/iostreams/doc/classes/zlib.html
这里值得一提的另一个选项是 boost。请注意,您必须使用特殊标志编译 boost 才能支持 zlib。
http://www.boost.org/doc/libs/1_48_0/libs/iostreams/doc/classes/zlib.html
Another option worth mentioning here is boost. Note you must compile boost with special flags for zlib support.
使用 zlib 最简单的方法是在 C++ 中使用
https://github.com/rudi-cilibrasi/zlibcomplete
zlibcomplete 库使这一切变得简单,因为您不需要进行任何原始指针操作。它基于 RAII(资源分配即初始化),这意味着所有动态分配和释放内容都会在构造函数中自动发生。
它比 Boost zlib 包装器更好,因为它支持刷新(交互式网络协议必需的)并且更易于使用。 zlibcomplete 库仅使用常规 std::string 来发送和接收数据,因此不需要高级知识。
The simplest way to use zlib is in C++ with
https://github.com/rudi-cilibrasi/zlibcomplete
The zlibcomplete library makes it easy because you don't need to do any raw pointer manipulation whatsoever. It is based on RAII (Resource Allocation is Initialization) which means that all the dynamic allocation and deallocation stuff happens automatically in the constructors.
It is better than the Boost zlib wrapper because it supports flush (necessary for interactive network protocols) and is simpler to use. The zlibcomplete library uses only regular std::string to send and receive data so no advanced knowledge is required.
最简单的方法是阅读
zpipe.c
,它有一个zlib 文档中的演练。它小巧而全面,实现并说明了压缩和解压缩。您可以仅复制、粘贴和修改数据流内容,例如,您可能不读取和写入文件,而是读取和写入内存。
需要注意的一件事:如果您正在处理 GZIP(而不是 deflate)(在发出 HTTP 请求时可能会发现这种情况),则需要将
inflateInit(&strm)
替换为inflateInit2( &strm, 16 + MAX_WBITS)
,因为 GZIP 具有更大的标头。The simplest approach is to read
zpipe.c
, which has a walk-through in zlib documentation.It is tiny and comprehensive, implements and illustrates compression and decompression. You can just copy and paste and modify the data stream stuff, for example you may not read and write to files but to memory.
One thing to notice: if you're handling GZIP (instead of deflate), which you may find when making a HTTP request, you need to replace
inflateInit(&strm)
withinflateInit2(&strm, 16 + MAX_WBITS)
, since GZIP has a bigger header.