Class UnicodeDecompressor


  • public final class UnicodeDecompressor
    extends Object
    A decompression engine implementing the Standard Compression Scheme for Unicode (SCSU) as outlined in Unicode Technical Report #6.

    USAGE

    The static methods on UnicodeDecompressor may be used in a straightforward manner to decompress simple strings:

      byte [] compressed = ... ; // get compressed bytes from somewhere
      String result = UnicodeDecompressor.decompress(compressed);
     

    The static methods have a fairly large memory footprint. For finer-grained control over memory usage, UnicodeDecompressor offers more powerful APIs allowing iterative decompression:

      // Decompress an array "bytes" of length "len" using a buffer of 512 chars
      // to the Writer "out"
    
      UnicodeDecompressor myDecompressor         = new UnicodeDecompressor();
      final static int    BUFSIZE                = 512;
      char []             charBuffer             = new char [ BUFSIZE ];
      int                 charsWritten           = 0;
      int []              bytesRead              = new int [1];
      int                 totalBytesDecompressed = 0;
      int                 totalCharsWritten      = 0;
    
      do {
        // do the decompression
        charsWritten = myDecompressor.decompress(bytes, totalBytesDecompressed, 
                                                 len, bytesRead,
                                                 charBuffer, 0, BUFSIZE);
    
        // do something with the current set of chars
        out.write(charBuffer, 0, charsWritten);
    
        // update the no. of bytes decompressed
        totalBytesDecompressed += bytesRead[0];
    
        // update the no. of chars written
        totalCharsWritten += charsWritten;
    
      } while(totalBytesDecompressed < len);
    
      myDecompressor.reset(); // reuse decompressor
     

    Decompression is performed according to the standard set forth in Unicode Technical Report #6

    Author:
    Stephen F. Booth
    See Also:
    UnicodeCompressor