Hi,
you made several faults:
1. PB uses Unicode for text, linux shell uses UTF8
2. echo without additional parameter adds always a LF at the end
to avaoid this you have to use -n as parameter
3. The string in PB has always a terminating 0 at the end.
4. If the supplied string is small, it is possible that the compressed result is larger as the string
(cause of the header for the compressed stuff)
A better version:
Code: Select all
UseLZMAPacker()
Procedure main()
Protected *test = UTF8("teste teste teste teste teste teste teste teste teste" + #LF$)
; + 32 for header stuff, so we are always safe
Protected *Output = AllocateMemory(MemorySize(*test) + 32)
; - 1 to eliminate the terminating 0
Protected compress_size = CompressMemory(*test, MemorySize(*test) - 1, *Output, MemorySize(*Output), #PB_PackerPlugin_Lzma)
; + 32 to be safe
Protected *uncompres_output = AllocateMemory(MemorySize(*test) + 32)
Protected uncompress_size = UncompressMemory(*Output, compress_size, *uncompres_output, MemorySize(*uncompres_output), #PB_PackerPlugin_Lzma)
Debug PeekS(*uncompres_output,uncompress_size, #PB_UTF8)
ShowMemoryViewer(*Output, compress_size)
EndProcedure
main()
Better and not good, because the result looks nearly identical, but the lzma header is different.
059E05E8 5D 00 00 00 02 00 3A 19 4A D7 09 02 9C 61 2E 9E ].....:.J×..a.
059E05F8 E3 DD FF FF FB 7E 90 00 ãÝÿÿû~.
The compressed bytes starting from 00 3A 19 ... are now identical.
But the 'header' is still different.
Bernd