'How to compress alphanumeric strings?
I want to shrink Strings like -1234B56789C;ABC1D3E/FGH4IJKL which are approx 20 - 25 case-insensitive chars.
My goal is to have an alphanumeric string that is a maximum of 16 characters. They must remain human readable.
Is that possible? Are there algorithms that can be used to compress alphanumeric string that also has some special chars?
It must also be possible to revert the compression.
Solution 1:[1]
You could attempt an LZW-like approach and look for common patterns in your input. For example - if you find that "1234" occurs often in your strings then you could encode that as "Q".
This approach cannot consistently achieve your requirements of a 16-character encoded string unless you can prove that the compression mappings you choose will always occur in the source with sufficient regularity to achieve a 16-character length.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OldCurmudgeon |
