Exemple #1
0
        private void SetSendMsg(uint key)
        {
            byte[] bs = SendDataCache.GetData(key);
            if (bs != null)
            {
                Encoding encode = Encoding.Default;
                if (this.rbtnUnicode.Checked)
                {
                    encode = Encoding.Unicode;
                }
                else if (this.rbtnAscii.Checked)
                {
                    encode = Encoding.ASCII;
                }
                else if (this.rbtnDefault.Checked)
                {
                    encode = Encoding.Default;
                }
                else if (this.rbtnutf8.Checked)
                {
                    encode = Encoding.UTF8;
                }
                else if (this.rbtnHex.Checked)
                {
                    // Hex
                }

                if (this.chkGzip.Checked)
                {
                    try
                    {
                        using (MemoryStream ms = new MemoryStream(bs))
                        {
                            using (GZipStream gs = new GZipStream(ms, CompressionMode.Decompress))
                            {
                                using (StreamReader sr = new StreamReader(gs, encode))
                                {
                                    this.txtEncode.Text = sr.ReadToEnd().Replace('\0', '.');
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this.txtEncode.Text = ex.Message;
                    }
                }
                else
                {
                    this.txtEncode.Text = encode.GetString(bs).Replace('\0', '.');
                }
            }
        }