Im working on an android project where I open a webpage. I have a listener if the user has no internet connection. Instead of displaying the standard "page could not be found" im giving the webview a local html file stored in my assets folder. By this line of code:
web.loadUrl("file:///android_asset/html/404error.html");
In the HTML-file i think the encoding? is "utf-8", and it says something with javascript, if thats relevant.
Everything works fine except when displaying "ÅÄÖ", all those characters gets replaced by a "?"
Does someone know the solution?
Thanks!
The browser/Webview needs to be told what encoding the document is in, otherwise it will guess some encoding or use the default one, which may be wrong. Usually you communicate the encoding using an HTTP header. If you're opening the file from local storage, obviously there's no HTTP involved. So you need to specify the encoding in the document header itself using
<meta http-equiv="Content-Type" content="text/html; charset=ENCODING HERE">
or, for HTML 5 documents:
<meta charset="ENCODING HERE">
Make sure the declaration matches how the document is actually encoded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With