流阅读器土耳其字符编码



如何解决这个问题?

string icerik;
WebRequest istek = HttpWebRequest.Create(adres);
istek.Proxy = null;
WebResponse cevap = istek.GetResponse();
CultureInfo tr = new CultureInfo("tr-TR");
StreamReader gelenBilgi = new StreamReader(cevap.GetResponseStream(), Encoding.GetEncoding(tr.TextInfo.ANSICodePage));
icerik = gelenBilgi.ReadToEnd();
htmlDoc.LoadHtml(icerik);

我尝试了一些方法来解决问题,但没有奏效。例如;

StreamReader gelenBilgi = new StreamReader(cevap.GetResponseStream(), Encoding.GetEncoding("iso-8859-9"));

StreamReader gelenBilgi = new StreamReader(cevap.GetResponseStream(), Encoding.GetEncoding("windows-1254"));

StreamReader gelenBilgi = new StreamReader(cevap.GetResponseStream(), Encoding.UTF8);

我遇到了同样的问题。这种方法帮助我解决了土耳其字符编码。

            string content;
            using (var sr = new StreamReader(cevap.GetResponseStream()))
            {
                Encoding iso = Encoding.GetEncoding("iso-8859-9");
                Encoding utf8 = Encoding.UTF8;
                byte[] utfBytes = utf8.GetBytes(sr.ReadToEnd());
                byte[] isoBytes = Encoding.Convert(utf8, iso, utfBytes);
                content = iso.GetString(isoBytes);
            }

相关内容

  • 没有找到相关文章

最新更新