title: Shorten an already short string in Java
body: <p>I'm looking for a way to shorten an already short string as much as possible.</p>
  
  <p>The string is a hostname:port combo and could look like "<em>my-domain.se:2121</em>" or "<em>123.211.80.4:2122</em>".</p>
  
  <p>I know regular compression is pretty much out of the question on strings this short due to the overhead needed and the lack of repetition but I have an idea of how to do it.</p>
  
  <p>Because the alphabet is limited to 39 characters (<em>[a-z][0-9]-:.</em>) every character could fit in 6 bits. This reduce the length with up to 25% compared to ASCII. So my suggestion is somthing along these lines:</p>
  
  <ol>
  <li>Encode the string to a byte array using some kind of custom encoding</li>
  <li>Decode the byte array to a UTF-8 or ASCII string (this string will obviously not make any sense).</li>
  </ol>
  
  <p>And then reverse the process to get the original string.</p>
  
  <p>So to my questions:</p>
  
  <ol>
  <li>Could this work?</li>
  <li>Is there a better way?</li>
  <li>How?</li>
  </ol>