Info about CompressString(String$) needed

Just starting out? Need help? Post your questions and find answers here.
Dirk Geppert
Posts: 330
Joined: Fri Sep 22, 2017 7:02 am

Info about CompressString(String$) needed

Post by Dirk Geppert »

Hello,

what kind of compression is CompressString(String$)? Help says: "Compress the specified string and returns a new compressed buffer. "

How can I unpack it again when I send the compressed text to a PB CGI tool?
Dirk Geppert
Posts: 330
Joined: Fri Sep 22, 2017 7:02 am

Re: Info about CompressString(String$) needed

Post by Dirk Geppert »

Seems #PB_PackerPlugin_Zip :D

Code: Select all

; Purebasic Code

UseBriefLZPacker ()
UseJCALG1Packer()
UseLZMAPacker()
UseTARPacker()
UseZipPacker()


Restore Packed

*mem = AllocateMemory(20)
*out = AllocateMemory(26)

For n = *mem To *mem + 19
 
  Read.b b
  PokeB(n, b)
  
Next



DecompressedLength = UncompressMemory(*mem, 20, *out, 26, #PB_PackerPlugin_BriefLZ)
Debug "#PB_PackerPlugin_BriefLZ"
Debug DecompressedLength
Debug PeekS(*out, DecompressedLength, #PB_Ascii)

DecompressedLength = UncompressMemory(*mem, 20, *out, 26, #PB_PackerPlugin_Zip)
Debug "#PB_PackerPlugin_Zip"
Debug DecompressedLength
Debug PeekS(*out, DecompressedLength, #PB_Ascii)

DecompressedLength = UncompressMemory(*mem, 20, *out, 26, #PB_PackerPlugin_Lzma)
Debug "#PB_PackerPlugin_Lzma"
Debug DecompressedLength
Debug PeekS(*out, DecompressedLength, #PB_Ascii)

DecompressedLength = UncompressMemory(*mem, 20, *out, 26, #PB_PackerPlugin_JCALG1)
Debug "#PB_PackerPlugin_JCALG1"
Debug DecompressedLength
Debug PeekS(*out, DecompressedLength, #PB_Ascii)


DataSection
  
  
Packed:
Data.b 120, -100, 115, 116, 114, 70, 3, 46, -82, 110, -18, 30, -98, 94, -34, 0, 92, 34, 6, -16, 0, 0, 0
EndDataSection



CompilerIf  0 

; SpiderBasic Code

String$ = "ABCCCCCCCCCCCCCCCCDEFGHIJK"
*Compressed = CompressString(String$)
Debug "Compressed size (from " + Len(String$) + " bytes): "+MemorySize(*Compressed)


For n = 0 To MemorySize(*Compressed) - 1
  Debug PeekB(*Compressed, n)
Next

CompilerEndIf
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Info about CompressString(String$) needed

Post by Fred »

Yes, it's zlib compression
Quin
Posts: 118
Joined: Wed Nov 08, 2023 4:38 pm

Re: Info about CompressString(String$) needed

Post by Quin »

Fred wrote: Thu Jul 04, 2024 11:39 am Yes, it's zlib compression
Would you consider putting this in the docs by chance? Could be useful info
idle
Posts: 20
Joined: Mon Feb 24, 2014 11:21 pm

Re: Info about CompressString(String$) needed

Post by idle »

Quin wrote: Thu Jul 11, 2024 5:48 pm
Fred wrote: Thu Jul 04, 2024 11:39 am Yes, it's zlib compression
Would you consider putting this in the docs by chance? Could be useful info
It should also specify if that it's deflate or gzip format. Same compressor but different headers
Post Reply