Hi nsstudios. The help is maybe not clear enough, but it's not nonsensical. You do understand these key facts, right:
- Compressed memory is smaller than the uncompressed original - by an amount that varies depending on the data
- Base64 encoded memory is LARGER than the original - by a fixed amount, a ~4:3 ratio
Seems like a copy paste, but what is the actual remark? Is it OK if it's the same size as compressed data, or does it need to be bigger, and by how much? If it's too big, will the packer resize it to the proper size?
No, it's not OK if the output buffer is the same size as compressed data... The uncompressed output data should always be larger!
No, the packer function will not resize the buffer larger for you. (Can Fred or someone from PB team confirm?)
How big is the uncompressed data? Well currently, that info should be stored with the compressed data, whether it's coming from a file, or another program, or compressed in another part of your program... For example see PackEntrySize() when working with ZIP files.
However, it would be a nice feature request option, for UncompressMemory() to automatically figure out the output size and provide a properly sized buffer back to you!
Seems like a partially modified copy-paste, but still unclear. Does the output buffer need to be 33% bigger, and what if it's too big, will Decoder resize the buffer to the proper size?
No, when decoding Base64 the output buffer does not need to be bigger, it can actually be smaller. The original data takes up LESS bytes than the encoded. It's sort of the opposite of compression.
Again, no, the function will not resize your buffer for you.
If you want to know the exact output buffer size needed, you can try my
Base64DecodeBytesNeeded() function here:
https://raw.githubusercontent.com/kenmo ... e64Lib.pbi
In fact, check out that whole includefile, it's my own Base64 library that's much more user friendly than PB's built-in Base64 library, and without the strange quirks like "a minimum size of 64 bytes" -- the Base64 algorithm does not have a minimum number of bytes (well, 1 byte, I guess) so I never understood why PureBasic has this 64-byte buffer requirement.