Decompress UInt
using System; using System.Collections.Generic; using System.Text; using System.Reflection; public static class Utility { public static uint DecompressUInt(byte[] data) { if (data == null) throw new ArgumentNullException("data"); if ((data[0] & 0x80 /* (1000000B) */) == 0 // ???????????0bbbbbbb B) && data.Length == 1) { return (uint)data[0]; } else if ((data[0] & 0xC0 /* (11000000B) */) == 0x80 /* (10000000B) */ // ???????????10bbbbbb bbbbbbbb B) && data.Length == 2) { return (uint)((data[0] & 0x3F /* (00111111B) */) << 8 | data[1]); } else if ((data[0] & 0xE0 /* (11100000B) */) == 0xC0 /* (11000000B) */ // ???????????110bbbbb bbbbbbbb bbbbbbbb bbbbbbbb B? && data.Length == 4) { return (uint)((data[0] & 0x1F /* (00011111B) */) << 24 | data[1] << 16 | data[2] << 8 | data[3]); } else { throw new NotSupportedException(); } } }