tag:blogger.com,1999:blog-3701737190756431503.post4075746111600462810..comments2024-01-16T03:43:59.407-05:00Comments on Yanniel's notes: String compression/decompression routines using DelphiUnknownnoreply@blogger.comBlogger8125tag:blogger.com,1999:blog-3701737190756431503.post-91583007301341058862015-08-07T02:43:40.027-04:002015-08-07T02:43:40.027-04:00You need to compress in client-side not in server-...You need to compress in client-side not in server-side, the end-user will thank you.franciscomurohttps://www.blogger.com/profile/03337982482965269755noreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-63591232305649214212013-09-04T09:57:42.078-04:002013-09-04T09:57:42.078-04:00Why use TStringStream for output? Use a TMemoryStr...Why use TStringStream for output? Use a TMemoryStream and return a byte array instead of string...<br />Because compressed data is binary...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-74957637241315799782013-06-20T07:59:53.973-04:002013-06-20T07:59:53.973-04:00I worked it out and thought it might be worth post...I worked it out and thought it might be worth posting. <br /><br />All the TStringStream components need to be created with Unicode encoding enabled (by default its Ansi). As per the following:<br /><br /> strInput := TStringStream.Create(Text, TEncoding.Unicode);<br /> strOutput := TStringStream.Create('', TEncoding.Unicode);Chris Nillissenhttps://www.blogger.com/profile/13867338340039793938noreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-42917987618959219132013-05-20T02:59:28.215-04:002013-05-20T02:59:28.215-04:00Thanks for the information!
But in your real life ...Thanks for the information!<br />But in your real life example you mention MySQL.<br />There is no need to compress/decompress anything in Delphi, just use the built-in MySQL functions COMPRESS() and DECOMPRESS().<br />They do the same zlib compression.<br />for example:<br /><br />INSERT INTO dummyTable(id, col1) VALUES (1, COMPRESS('This is a long string'));<br /><br />will insert the string zlib compressed, and you can retrieve it with:<br /><br />SELECT id, UNCOMPRESS(col1) FROM dummyTable;<br /><br />I use this method and it saves me from extra coding.Anonymoushttps://www.blogger.com/profile/13766800216038704130noreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-87265923786394143402012-08-29T21:08:21.267-04:002012-08-29T21:08:21.267-04:00I don't have a Unicode version of Delphi (2009...I don't have a Unicode version of Delphi (2009 and above) to try this right now, but I will install it and I'll let you know my findings. Thanks.Crisis Fix Adminhttps://www.blogger.com/profile/05146301387107261870noreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-88894500974468555142012-08-28T23:47:24.871-04:002012-08-28T23:47:24.871-04:00I tried using this but it doesnt seem to preserve ...I tried using this but it doesnt seem to preserve Unicode characters. Try putting some Chinese characters in and when decompressed it looses the encoding. Chris Nillissenhttps://www.blogger.com/profile/13867338340039793938noreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-26103930033355665422011-11-12T06:07:40.565-05:002011-11-12T06:07:40.565-05:00Indeed, the ZLib unit shipped with Delphi 7 does n...Indeed, the ZLib unit shipped with Delphi 7 does not contain the classes TZCompressionStream and TZDecompressionStream. Try a higher version, 2007 for example ;-) <br /><br />For Delphi 7, you’ll need to use the ZCompressStr and ZDecompressStr methods.Crisis Fix Adminhttps://www.blogger.com/profile/05146301387107261870noreply@blogger.comtag:blogger.com,1999:blog-3701737190756431503.post-91520388792248267492011-11-12T04:48:33.655-05:002011-11-12T04:48:33.655-05:00Sorry, it doesn't work with Delphi 7!Sorry, it doesn't work with Delphi 7!Anonymousnoreply@blogger.com