0

Text I am reading from a XML, which is suppose to be a string with base64 encoded and Gzip compressed. I am following the below steps:

 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);
   }

I am getting myStr value as something like :

�\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�ϕ��{�"

I am expecting adecoded string. Any hint on this is much appreciated.

Thanks in Advance. :)

Anand
  • 823
  • 1
  • 10
  • 19
  • Well what was the original data? Was it definitely text? It would help if you'd show a complete program, with encoding *and* decoding. Note that you could just create a `reader` for `outStream` instead of copying it... – Jon Skeet Nov 07 '14 at 14:12
  • Yes it is a text. I have updated my code.. @ Jon Skeet – Anand Nov 07 '14 at 14:17
  • Your update doesn't show the encoding at all, nor is it a complete program. We should be able to copy, paste, compile, run and see the problem. – Jon Skeet Nov 07 '14 at 14:17
  • I am not suppose to do the encoding... My input is an XML which I need to parse to get certain value of a node, which is suppose to be base 64 encoded and Gzipped compressed. – Anand Nov 07 '14 at 14:23
  • I dare say it's *supposed* to be that - but we can't possibly verify that. It could easily be a problem on the encoding side, as far as we know. – Jon Skeet Nov 07 '14 at 14:24

0 Answers0