public string CompressDebug(string input)
        {
            var bytes           = Encoding.UTF8.GetBytes(input);
            var consumerContext = new StringWriter();

            _substringPacker.Pack(bytes, new DebugPackerOutput(), consumerContext);
            return(consumerContext.GetStringBuilder().ToString());
        }
Example #2
0
        public CompressionHandler CreateHandler(int desiredLength = 1024 *32)
        {
            var dictionary = _dictionaryOptimizer.Optimize(desiredLength);
            var training   = new SubstringPacker(dictionary);

            var huffmanTableTrainer = new HuffmanTableTrainer();

            foreach (var document in _dictionaryOptimizer.Documents)
            {
                training.Pack(document, huffmanTableTrainer, null);
            }

            var packer = huffmanTableTrainer.GeneratePacker();

            return(new CompressionHandler(dictionary, packer));
        }