formatting encoding .net

0

Alright? I have a problem that is as follows: I retrieve the html from a legacy system and, I need to change that html pa then return to the browser with the new html. But when I retrieve this report the words with ç and accents, are with special characters, eg Impression. NOTE: This problem occurs when html is retrieved, because the page recovered, run smoothly in production.

The charset used on this page is iso-8859-1. I use webrequest

 var request = WebRequest.Create(url);
 var response = request.GetResponse();
 var dataStream = response.GetResponseStream();
 var reader = new StreamReader(dataStream);
 htmlFicha = reader.ReadToEnd();

I tried, to replace, to substitute for the correct word, but tb did not work. How do I fix this problem? Thank you very much.

    
asked by anonymous 07.12.2018 / 18:34

1 answer

2

Try passing the Encoding as a parameter in StreamReader :

var request = WebRequest.Create(url);
var response = request.GetResponse();
var dataStream = response.GetResponseStream();
var reader = new StreamReader(dataStream, Encoding.GetEncoding("iso-8859-1"), true);
htmlFicha = reader.ReadToEnd();
    
07.12.2018 / 19:10