Esempio n. 1
0
        static void Main(string[] args)
        {
            var k = new Xiao();

            foreach (var str in strings)
            {
                var bytes        = Encoding.UTF8.GetBytes(str);
                var output       = new byte[256];
                var size         = k.Compress(bytes, output);
                var decompressed = new byte[256];
                var newSize      = k.Decompress(output, size, decompressed);
                var s            = Encoding.UTF8.GetString(decompressed, 0, newSize);
                if (s != str)
                {
                    Console.WriteLine("Opps");
                    break;
                }
                Console.WriteLine($"{size} from {bytes.Length} = {1 - (size/(double)bytes.Length):p} - {str}");
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var k = new Xiao();

            foreach (var str in strings)
            {
                var bytes = Encoding.UTF8.GetBytes(str);
                var output = new byte[256];
                var size = k.Compress(bytes, output);
                var decompressed = new byte[256];
                var newSize = k.Decompress(output, size, decompressed);
                var s = Encoding.UTF8.GetString(decompressed, 0, newSize);
                if (s != str)
                {
                    Console.WriteLine("Opps");
                    break;
                }
                Console.WriteLine($"{size} from {bytes.Length} = {1 - (size/(double)bytes.Length):p} - {str}");
            }
        }