title: Compressing simple text to text
body: <p>I have a bunch of long strings (16200 characters) that I want to compress. The entire string only uses 12 different characters (currently _oOwWgGmdDsS and, but those can change if needed).</p>
  
  <p>I'm looking to compress this string. I currently made a compression scheme myself, where each time I first put the character, and then how many times it appears before another one is in the string. So if the uncompressed text looks like this:</p>
  
  <pre><code>ooooooWW_
  </code></pre>
  
  <p>Then the compressed becomes</p>
  
  <pre><code>o6W2_1
  </code></pre>
  
  <p>For the strings I currently have this reduced the size from about 128MB to 4MB. However, as you can see, for the W's there is no saving, and for the _ there's even a loss.</p>
  
  <p>So I was wondering, are there more sophisticated compression schemes I can use? The end result has to be plain text however, not binary data.</p>
  
  <p>Note: It would also be awesome if there exists a library for both Python and Lua for them.</p>