title: Binary run length encoding
body: <p>I have a web form, for the contents of which I would like to generate a short representation in Base64. The form, among other things, contains a list of 264 binary values, the greater part of which are going to be 0 at any single time. (They represent regions on a geographical map). Even in Base64, this 264-bit number generates a long, intimidating string. I want to implement run-length encoding, as efficiently as possible. Can you help me with this? I've googled binary RLE, but have found nothing of use.</p>
  
  <p><strong>What I've tried this far</strong> - running RLE on the binary string using decimal counts and "A" as a separator denoting a change between 0 and 1, then converting the result from base 11 to base 64. For example:</p>
  
  <pre><code>00000000001111111000000010000000000000000000000001111111110001111010101000000000000000000000000000000000000111111111110111000000000000111111100000001000000000000000000000000111111111000111101010100000000000000000000000000000000000011111111111011100
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>10A5A5AA22A7A1A2AAAAAAA34A9AA1A10A5A5AA22A7A1A2AAAAAAA34A9AA1A
  </code></pre>
  
  <p>which in turn becomes</p>
  
  <pre><code>CNnbr/FxkgbbOw0LNAKgk65P8SdvaTG+t74o
  </code></pre>
  
  <p>or, in base 62,</p>
  
  <pre><code>6imo7zq1pqr2mqglTHzXwJRAksm7fvHZHWQK
  </code></pre>
  
  <p>It's better, but I still can't help but doubt if I'm doing something wrong - is using the digit "A" as a separator is the best way to do this?</p>
  
  <p><strong>And another update:</strong></p>
  
  <p>Thanks to <strong>@comingstorm</strong>, I have shortened the compressed string some more.</p>
  
  <pre><code>ILHHASCAASBYwwccDASYgAEgWDI=
  </code></pre>
  
  <p>As I mentioned it in the comments, real usage cases would generally result in an even shorter string.</p>