lithestring

Synopsis

Java class to compress short (or long) strings

Motivation

I dreamed a compression algorithm expecially useful for short strings, without fear of taking up more space than the UTF-8 encoding of the original string.

The compression algorithm chooses the best approach between:

The decompression algorithm looks if it is a plain UTF-8 encoding or a compressed one, and in the latter case reads the data header to apply the correct decoding algorithm.

Code Example

String input = ...;
byte[] compressed = LitheString.zip(input); // in the worst case, compressed is the plain UTF-8 encoding of input
String uncompressed = LitheString.unzip(compressed);

if (input.equals(uncompressed)){
    System.out.println("It works!");
} else {
    System.out.println("Please submit a bug for "+input);
}

Author

License

LGPL-2.1