如何从base64编码的gzip压缩文本中获取未编码的字符串

时间:2014-11-07 14:09:52

标签: c#-4.0 base64 gzipstream

Text我正在读取XML,它假设是一个带有base64编码和压缩Gzip的字符串。我遵循以下步骤:

 string text = childNodes.Item(i).InnerText.Trim();
 byte[] compressed = Convert.FromBase64String(text);
 byte[] compressed = Convert.FromBase64String(text);
 using (var uncompressed = new MemoryStream())
 using (var inStream = new MemoryStream(compressed))
 using (var outStream = new GZipStream(inStream, CompressionMode.Decompress))
   {
       outStream.CopyTo(uncompressed);
       var reader = new StreamReader(uncompressed);
       uncompressed.Position = 0;
       string myStr = reader.ReadToEnd();
       Console.WriteLine(myStr);
   }

我的myStr值如下:

�\b\0\0\0\0\0\0Ľk��ƒ �Y��ؘX{���z:�n�,ɏ�ek��xϞ�`�\0؍�|\t ��_3�\n(\0$�s.Cb�\0*3++��|
͛ �-7�6�fW\r\t�\b���W\"�\n�ə��L&���Ez�-����E��\t�%���/���O��Q����
 i�����]�T�b�<_�dŦ�W۫���ܭn^[X�ϕ��{�"

我期待编码的字符串。任何暗示都非常感谢。

先谢谢。 :)

0 个答案:

没有答案