Heisenbug
Heisenbug

Reputation: 970

NSString compression based on repeating substrings, or differences between 2 strings

i have stream of base64 encoded image strings and there are lots of repeating substrings. I would like to save some space by compressing them somehow (and decompressing them back). I am also open for another solutions of saving space, like sending only diffecences between two strings.

What is the best practice to do so ? Thanks in advance.

Edit
What in case I need to compress data on windows and decompress in iOS ? On osx I'll try this lib https://github.com/nicklockwood/GZIP

Upvotes: 0

Views: 271

Answers (1)

Avi
Avi

Reputation: 7552

I recommend using gzip compression. You can find a simple category for NSData by Nick Lockwood, called GZIP. It's trivial to write a category on NSString that does the two step conversion for you: NSString->NSData->Compressed NSData.

Upvotes: 1

Related Questions