I tried to get this to work, but now I'm very upset. I am new to this area, so maybe I'm just wrong.
What I need to do is take the .html website and save it in a txt file. Now the problem is that this site is in Russian (windows-1251 encoding), and Silverlight only supports 3 encodings. Therefore, to get around this limitation, I got an encoding class that passes a stream to an array of bytes, and then tries to extract a correctly encoded string from the text. The problem is
1) I am trying to ensure that webClient receives a Unicode encoded stream, because others do not seem to create a recoverable string, but it still does not work.
WebClient wc = new WebClient();
wc.Encoding = System.Text.Encoding.Unicode;
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_LoadCompleted);
wc.DownloadStringAsync(new Uri(site));
2) I'm afraid that when I store the html in a txt file using streamWriter, the encoding, again, is somehow messed up. 3) The coding class does not do its job.
Encoding rus = Encoding.GetEncoding(1251);
Encoding eng = Encoding.Unicode;
byte[] bytes = rus.GetBytes(string);
textBlock1.Text = eng.GetString(bytes);
Can anyone help on this? This is a huge damage to my project. Thanks in advance,
source
share