title: storing strings in an array in a compact way
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/845324/text-packing-algorithm">Text packing algorithm</a>  </p>
  </blockquote>
  
  
  
  <p>The setup: I have a bunch of strings which should be put into an (one-dimensional) array, and which are accessed with an offset and a string length.</p>
  
  <p>The problem: Find an algorithm to store those strings as efficiently as possible.</p>
  
  <p>Example: Consider the three strings <code>foo</code>, <code>foobar</code>, and <code>array</code>.  The most compact form would be <code>foobarray</code>: <code>foo</code> gets accessed with offset 0 and length 3 (0,3) , <code>foobar</code> with (0,6), and <code>array</code> with (4,5).</p>
  
  <p>Note that the access of the array with offset and length is mandatory (this is actually the method how the data in the `name' table of an OpenType font is stored).</p>
  
  <p>I'm quite sure that solutions already exist, but I'm probably missing the right keyword to find them in the internet.</p>
  
  <p>Please advise.</p>