code: public static byte [] compress(char [] buffer,
                     int start,
                     int limit)
      {
      UnicodeCompressor comp = new UnicodeCompressor();
  
      // use a buffer that we know will never overflow
      // in the worst case, each character will take 3 bytes
      // to encode: UQU, hibyte, lobyte.  In this case, the
      // compressed data will look like: SCU, UQU, hibyte, lobyte, ...
      // buffer must be at least 4 bytes in size
      int len = Math.max(4, 3 * (limit - start) + 1);
      byte [] temp = new byte [len];
  
      int byteCount = comp.compress(buffer, start, limit, null, 
                        temp, 0, len);
  
      byte [] result = new byte [byteCount];
      System.arraycopy(temp, 0, result, 0, byteCount);
      return result;
      }
docs: Compress a Unicode character array into a byte array.
  @param buffer The character buffer to compress.
  @param start The start of the character run to compress.
  @param limit The limit of the character run to compress.
  @return A byte array containing the compressed characters.
  @see #compress(String)