How to compress alphanumeric strings?

I want to compress strings like -1234B56789C;ABC1D3E/FGH4IJKL , which are approximately 20-25 characters case insensitive.

My goal is to have an alphanumeric string, which is a maximum of 16 characters. They must remain human readable.

Is it possible? Are there algorithms that can be used to compress an alphanumeric string that also has some special characters?

It is also necessary to return compression.

+5
source share
2 answers

I think this is generally not possible unless you use a different target alphabet.
As far as I understand, your source alphabet is 0-9 and AZ.
If you add target alphabet to include also some N> 0 other characters,
then you can encode the input string with fewer characters that it originally had. (because, for example, you can encode pairs of characters from the source alphabet using one char from the target alphabet).

+2
source

You can try the LZW-like approach and look for common patterns at your input. For example, if you find that “1234” is often found on your lines, then you can encode this as “Q”.

This approach cannot consistently fulfill your requirements for a 16-character encoded string unless you can prove that the compression comparisons you choose will always occur in the source with sufficient regularity to achieve a length of 16 characters.

+2
source

Source: https://habr.com/ru/post/1208256/


All Articles