Hello,
i load a webpage into a string and remove some elements(divs in content). Then i try to show the html page in webview. That works but all german umlaute are shown as "?"
I tried several ways for a few hours but i cant get it working...
Fiddler is showing this as header for the loaded url:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
The header of the html shows that:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="yes, all, follow,index" />
<meta name="revisit-after" content="1 days" />
<meta http-equiv="Content-Language" content="de" />
Im loading it in simplest way like that:
`
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Books);
var myWebView = FindViewById<WebView>(Resource.Id.webview);
string url = "http://m.cetpm.de/shop.html?kat=1";
var url2 = new Uri(url);
HttpWebRequest http = (HttpWebRequest)WebRequest.Create(url2);
//headers
http.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36";
http.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
http.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
http.Headers.Add("Accept-Language", "de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4");
http.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
using (WebResponse response = http.GetResponse()) {
var reader = new StreamReader(response.GetResponseStream());
var result = reader.ReadToEnd();
var wc = new WebViewClient();
myWebView.SetWebViewClient(wc);
myWebView.LoadDataWithBaseURL(null, result, "text/html", "utf-8", null); //"utf-8" iso-8859-1
}
}
`
I hope you can help me!
Best reagrds,
Simon