compression

GZipStream: why do we convert to base 64 after compression?

£可爱£侵袭症+ 提交于 2019-12-07 15:55:23
问题 I was just looking at a code sample for compressing a string. I find that using the GZipStream class suffices. But I don't understand why we have to convert it to base 64 string as shown in the example. using System.IO.Compression; using System.Text; using System.IO; public static string Compress(string text) { byte[] buffer = Encoding.UTF8.GetBytes(text); MemoryStream ms = new MemoryStream(); using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true)) { zip.Write(buffer, 0,

Compressing a sparse bit array

时间秒杀一切 提交于 2019-12-07 14:51:39
问题 I have arrays of 1024 bytes (8192 bits) which are mostly zero. Between 0.01% and 10% of bits will be set (random, no pattern). How could these be compressed, given the lack of structure and the relatively small size? (My first thought was to store the distances between set bits. I need 13 bits for each distance, but at worst case 10% occupancy this needs 13 * 816 / 8 = 1326 bytes, which is not an improvement.) This is for ultra-low bandwidth comms, so every byte matters. 回答1: I've dealt

Client side data compress/decompress? [closed]

Deadly 提交于 2019-12-07 13:46:36
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm looking for a JavaScript implementation of a string compress/decompress algorithm where data is created at the client side and stored in hidden fields within HTML forms. I read about gzip, but it compresses the data server side whereas in my case I want to compress it client side, send it to the server, or

Can PHP decompress a file compressed with the .NET GZipStream class?

限于喜欢 提交于 2019-12-07 12:44:43
问题 I have a C# application that communicates with a PHP-based SOAP web service for updates and licensing. I am now working on a feedback system for users to submit errors and tracelogs automatically through the software. Based on a previous question I posted, I felt that a web service would be the best way to do it (most likely to work properly with least configuration). My current thought is to use .NET built-in gzip compression to compress the text file, convert to base64, send to the web

Boost Iostreams zlib_error with Custom Source

爷,独闯天下 提交于 2019-12-07 10:40:50
问题 I am trying to use a zlib_decompressor to decompress data through an istreambuf_iterator . I couldn't find an in built way to use an input iterator as input to a stream (please point out a way if one exists already) so I wrote this source: template <class cha_type, class iterator_type> class IteratorSource { public: typedef cha_type char_type; typedef boost::iostreams::source_tag category; iterator_type& i; iterator_type eof; IteratorSource(iterator_type& it, iterator_type end) : i(it), eof

Shorten an already short string in Java

喜欢而已 提交于 2019-12-07 10:08:49
问题 I'm looking for a way to shorten an already short string as much as possible. The string is a hostname:port combo and could look like " my-domain.se:2121 " or " 123.211.80.4:2122 ". I know regular compression is pretty much out of the question on strings this short due to the overhead needed and the lack of repetition but I have an idea of how to do it. Because the alphabet is limited to 39 characters ( [a-z][0-9]-:. ) every character could fit in 6 bits. This reduce the length with up to 25%

PPMD compression in Java?

别说谁变了你拦得住时间么 提交于 2019-12-07 09:36:46
问题 Does anyone know of a Java implementation of the PPMD compression algorithm? I have not been able to find a Java implementation, but there is a C# implementation at http://users.senet.com.au/~mjbone/Compression.html that is about 4k lines of code. I'm not going to ask if anyone feels like porting it to Java... 回答1: I was using for the same implementation, and couldn't find any. But I found that 7zip gives the source code of their ppmd implementation just in C++, not in java (at least, until

Does compressing an image make the image use less memory? [closed]

感情迁移 提交于 2019-12-07 08:57:12
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . This is sort of an architectural/conceptual question regarding how a system (specifically a web browser) handles compressed images. We're dealing with an "image gallery" web app at work that has eleven 1920x1080

One library for deflate, gzip, and zlib in .net

给你一囗甜甜゛ 提交于 2019-12-07 08:46:06
问题 First, let's define some commonly confused terms: deflate = compression_algorithm; zlib = header + deflate + trailer; gzip = header + deflate + trailer; I'm looking for a library that will basically let me do the following: if(method == "gzip"){ Response.Filter = new CompressionLibrary.OutputStream(Response.Filter, CompressionLibrary.Formats.GZIP); } else if(method == "deflate"){ Response.Filter = new CompressionLibrary.OutputStream(Response.Filter, CompressionLibrary.Formats.DEFLATE); } else

Duplicate text-finding

半世苍凉 提交于 2019-12-07 07:25:23
问题 My main problem is trying to find a suitable solution to automatically turning this, for example: d+c+d+f+d+c+d+f+d+c+d+f+d+c+d+f+ into this: [d+c+d+f+]4 i.e. Finding duplicates next to each other, then making a shorter "loop" out of these duplicates. So far I have found no suitable solution to this, and I look forward to a response. P.S. To avoid confusion, the aforementioned sample is not the only thing that needs "looping", it differs from file to file. Oh, and this is intended for a C++