Пример #1
0
        public string Decode(byte[] data)
        {
            var reader = new BitReader(data);
            while (reader.Remain > 8)
            {
                var start = reader.ReadByte();
                if (start == 2)
                    break;
            }
            var len = reader.ReadInt(16);
            var result = new StringBuilder(len);
            for (int i = 0; i < len; i++)
            {
                var b = reader.ReadInt(7);
                var ch = Convert.ToChar(b);
                result.Append(ch);
            }

            return result.ToString();
        }
Пример #2
0
        public string Decode(byte[] data)
        {
            var reader = new BitReader(data);
            while(reader.Remain > 8)
            {
                var start = reader.ReadByte();
                if (start == 2)
                    break;
            }
            var len = reader.ReadInt(16);
            var result = new StringBuilder(len);
            for (int i = 0; i < len; i++)
            {
                var index = reader.ReadInt(6);
                var ch = Dict.Custom[index];
                result.Append(ch);
            }

            return result.ToString();
        }
Пример #3
0
 private void ShowBinString()
 {
     Task.Factory.StartNew(() =>
     {
         if (buff == null) return;
         var reader = new BitReader(buff);
         var byteLen = reader.Length / 8;
         var format = "D" + byteLen.ToString().Length;
         var bin = new StringBuilder();
         for (int i = 0; i < byteLen; i++)
         {
             bin.Append(i.ToString(format)).Append(" ").Append(reader.ReadBinString(8)).Append("\r\n");
         }
         Dispatcher.BeginInvoke(new Action(() =>
         {
             BinText.Text = bin.ToString();
         }));
     });
 }