in reply to How to efficently pack a string of 63 characters

From your problem statement, you have not only just ASCII characters but only upper case ASCII, not binary data. I would go "old school" and use the Baudot_code. This gets each 8 bit byte to 5 bits. Shifting between upper and lower case can be done but requires an additional "control" character.

The advantage of this is that this is a well known standard that is still in use today. There is nothing tricky or fancy about this. That means that it can be done very efficiently. 8 bits -> 5 bits according to a standard protocol.

Update: That means that 3 of every 8 bits are not needed. 3/8 means, 37.5% compression for almost nothing.

Also if this is true: "One can assume a random distribution of characters from Alphabet A = {A, B, C}". There is not much that you can do past baudot code. Random data cannot be compressed. Oh, I perhaps see now, the alphabet will be limited to a set less than 26 characters. In that case, perhaps make your own version of the Baudot code? Perhaps send a block of translation tables before the actual data? It does appear to me that you can achieve a huge amount of compression with a table driven, very efficient algorithm.

  • Comment on Re: How to efficently pack a string of 63 characters