I am parsing some web content in a response from a HttpWebRequest
.
This web content is using charset ISO-8859-1
and when parsing it and finally getting the word needed from the response, I am receiving a string
with a question mark like this �
and I want to know which is the right way to transform it back into a readable string
.
So, what I've tried is to convert the current word encoding
into UTF-8
like this:
(I am wondering if UTF-8
could solve my problem)
string word = "ESPA�OL";
Encoding iso = Encoding.GetEncoding("ISO-8859-1");
Encoding utf = Encoding.GetEncoding("UTF-8");
byte[] isoBytes = iso.GetBytes(word);
byte[] utfBytes = Encoding.Convert(iso, utf, isoBytes);
string utfWord = utf.GetString(utfBytes);
Console.WriteLine(utfWord);
However, utfWord
variable outputs ESPA?OL
which is still wrong. The correct output is supposed to be ESPAÑOL
.
Can someone please give me the right directions to solve this, if possible?