in reply to Binary string to base64
A couple of notes:
If you're trying to compress the data into a "safe" form for transmission, you might want to try pack's 'w' data type, which will put data into a 7-bit (base 128) form, which will squeeze out a little.
I'm not aware of a standard representation for base32 representation, but it's easy enough to come up with one.
If you're trying to compress data only, short strings don't tend to compress all that well with most compression schemes as they learn from the data you're trying to compress. If the data has some structure or pattern that you know, you can enforce a coding scheme on top of it. For example, one scheme I've seen for compressing numbers relied on the fact that most numbers in the application are small, but they had to have a 32-bit (unsighed) range. So we encoded them such that a number under 128 would be represented in a single byte with the topmost bit equal to 0, numbers under 16384 were represented as a two-byte number with the top two bits set to 01, and all the others were represented with a five-byte number with the top two bits set to 11. Sure, the larger numbers were longer that 32 bits, but the small numbers were so frequent that it compressed very well. (We could've chopped the range again, but it was more effort for insignificant payoff...)
I hope this helps...
--roboticus
|
|---|