Compression of ASCII strings in C

前端 未结 6 1570
梦如初夏
梦如初夏 2021-01-02 03:55

I have some C code that stores ASCII strings in memory as a four byte length followed by the string. The string lengths are in the range 10-250 bytes.

To reduce occ

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-02 04:53

    Most compression algorithms don't work very well with short strings. Here are a few compression algorithms that are designed to compress short English text strings. While they can handle any arbitrary byte in the plaintext string, such bytes often make the "compressed" data longer than the plaintext. So it's a good idea for the compressor to store "uncompressible" data unchanged and set a "literal" flag on such data (as Steve Jessop suggested).

    • "base 40 encoding": maximum compression 3:2
    • "Zork Standard Code for Information Interchange" (ZSCII): maximum compression 3:2
    • byte pair compression: maximum compression 2:1
    • a static Huffman table shared among all the strings (as suggested out by cygil).
      • ideally, formed from the exact character frequencies of all of your actual data.
      • Varicode: maximum compression 2:1
    • PalmDoc compression (byte pair compression + a simple variant of LZ77).

提交回复
热议问题