String compression method.