encoding formatting . net

Asked

Viewed 61 times

1

all right? With a problem that is as follows: I recover the html of a legacy system and, I need to change this html pa then return to the browser with the new html. But when I recover this report the words with tones and accents, are with special characters, e.g.: Impress the. OBS.: This problem occurs when html is recovered, because the recovered page, executed without problems 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 it to replace it with the right word, but it didn’t work. How do I fix this problem? thank you very much.

1 answer

0


Try to pass the Encoding desired as 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();
  • Kra vlw...worked out!!!!! thank you very much

  • For nothing, I hug ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.