I am going to show you an script which can help you to to compress the string. Compress and uncompressing of strings uses the deflate algorithm.
In the following method of compression of a string,first the whole string is converted into the specified character set which would be necessary for programming languages where strings are represented as 2-byte/char Unicode.
Code:
require 'chilkat'
gzip = Chilkat::CkGzip.new()
success = gzip.UnlockComponent("Anything for 30-day trial")
if (success != true)
print gzip.lastErrorText() + "\n"
exit
end
s = "A friend called me for surfing on the internet "
s = s + " But I was too let to go with him..."
s = s + s
s = s + s
cs = gzip.deflateStringENC(s,"windows-1252","base64")
print cs + "\n";
s2 = gzip.inflateStringENC(cs,"windows-1252","base64")
print s2 + "\n";
Bookmarks