How do i use zlib
Code Revisions 7 Stars 57 Forks Embed What would you like to do? Embed Embed this gist in your website. Share Copy sharable link for this gist. Learn more about clone URLs. Download ZIP. Compress and then Decompress a string with zlib. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. And finally a Makefile for us to compile by running only the make command.
Well, simple, right?! This is just an example for single files, for more details see the documentation:. I organized it into 4 files that are: zpipe. Simply read in your data from the file like you normally would and call the compress method. The compressed data can also be saved to a file for later use. The example below shows how to save some compressed text into a file:. The above example compresses our simple "Hello world" string and saves the compressed data into a file named "outfile.
The "outfile. A compressed string of data can be easily decompressed by using the decompress function. This function decompresses the bytes in the data argument. The wbits argument can be used to manage the size of the history buffer. The default value matches the largest window size. It also asks for the inclusion of the header and trailer of the compressed file. The possible values are:. The initial value of the buffer size is indicated in the bufsize argument. However, the important aspect about this parameter is that it doesn't need to be exact, because if extra buffer size is needed, it will automatically be increased.
The following example shows how to decompress the string of data compressed in our previous example:. Decompressing big data streams may require memory management due to the size or source of your data. It's possible that you may not be able to use all of the available memory for this task or you don't have enough memory , so the decompressobj method allows you to divide up a stream of data in to several chunks which you can decompress separately.
This function returns a decompression object, which what you use to decompress the individual data. The wbits argument has the same characteristics as in decompress function previously explained. The following code shows how to decompress a big stream of data that is stored in a file. Muhammad Shahab Muhammad Shahab 5, 4 4 gold badges 36 36 silver badges 47 47 bronze badges. I would recommend that first article — bobobobo.
The second link is dead. It is actually working fine at my end. It redirects to : codeguru. Derick Schoonbee Derick Schoonbee 2, 1 1 gold badge 21 21 silver badges 37 37 bronze badges.
Ben Ben 8 8 silver badges 14 14 bronze badges. Rudi Cilibrasi Rudi Cilibrasi 4 4 silver badges 11 11 bronze badges. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked 3.
0コメント