{"action":"opened","issue":{"url":"https://api.github.com/repos/NativeScript/NativeScript/issues/1038","labels_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/1038/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/1038/comments","events_url":"https://api.github.com/repos/NativeScript/NativeScript/issues/1038/events","html_url":"https://github.com/NativeScript/NativeScript/issues/1038","id":115248746,"number":1038,"title":"WebView with HTML string source does not render on old Android","user":{"login":"emiloberg","id":4673048,"avatar_url":"https://avatars.githubusercontent.com/u/4673048?v=3","gravatar_id":"","url":"https://api.github.com/users/emiloberg","html_url":"https://github.com/emiloberg","followers_url":"https://api.github.com/users/emiloberg/followers","following_url":"https://api.github.com/users/emiloberg/following{/other_user}","gists_url":"https://api.github.com/users/emiloberg/gists{/gist_id}","starred_url":"https://api.github.com/users/emiloberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emiloberg/subscriptions","organizations_url":"https://api.github.com/users/emiloberg/orgs","repos_url":"https://api.github.com/users/emiloberg/repos","events_url":"https://api.github.com/users/emiloberg/events{/privacy}","received_events_url":"https://api.github.com/users/emiloberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-05T10:00:04Z","updated_at":"2015-11-05T10:00:04Z","closed_at":null,"body":"It seems like older versions of Android doesn't render the WebView correctly when given a WebView with a `src` set to a HTML string.\r\n\r\nEasiest describe with an example, given a simple page page like this:\r\n\r\n```\r\n<Page xmlns=\"http://www.nativescript.org/tns.xsd\" loaded=\"pageLoaded\">\r\n\t<GridLayout rows=\"*\" columns=\"*\" id=\"container\" />\r\n</Page>\r\n```\r\n\r\nAnd a Javascript file which just sets the `src` of the WebView to an HTML string:\r\n\r\n```\r\nvar webViewModule = require('ui/web-view');\r\nvar gridLayout = require('ui/layouts/grid-layout');\r\n\r\nfunction pageLoaded(args) {\r\n\tpage = args.object;\r\n\tvar wv = new webViewModule.WebView();\r\n\tvar container = page.getViewById('container');\r\n\tgridLayout.GridLayout.setColumn(wv, 0);\r\n\tgridLayout.GridLayout.setRow(wv, 1);\r\n\tcontainer.addChild(wv);\r\n\r\n\twv.src = '<!DOCTYPE html>' +\r\n\t\t'<html lang=\"en\">' +\r\n\t\t'<head>' +\r\n\t\t\t'<meta charset=\"utf-8\">' +\r\n\t\t\t'<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">' +\r\n\t\t\t'<meta name=\"viewport\" content=\"width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, user-scalable=0\" />' +\r\n\t\t\t'<title>Test Page</title>' +\r\n\t\t'</head>' +\r\n\t\t'<body>' +\r\n\t\t\t'<h1>Hi there</h1>' +\r\n\t\t\t'<h2>Here are some Swedish characters: ÅÄÖ</h2>' +\r\n\t\t'</body>' +\r\n\t\t'</html>';\r\n}\r\n\r\nexports.pageLoaded = pageLoaded;\r\n```\r\n\r\nThe above works perfectly on all my devices. However, I've got a bug report from a user running Android 4.3/API 18 (on a Samsung Galaxy S3). On her device, the WebView displays the HTML code:\r\n\r\n![4216470493659screenshot_2015-10-29-12-08-51](https://cloud.githubusercontent.com/assets/4673048/10964605/79c09a54-83a8-11e5-92e3-728784a9fba4.png)\r\n\r\nAfter a long time debugging, it looks like her 4.3 device doesn't understand the MIME type `text/html; charset=utf-8` set in [web-view.android.ts](https://github.com/NativeScript/NativeScript/blob/master/ui/web-view/web-view.android.ts#L101-L125), and renders it as `text/plain` instead.\r\n\r\nWhen removing the `; charset=utf-8` part on both places in the file linked above, it worked and rendered as it should.\r\n\r\nHowever. The `; charset=utf-8` part was added (by me in [this PR](https://github.com/NativeScript/NativeScript/pull/845)) because internet suggested it was needed for UTF-8 characters to work on some API versions. (E.g. [StackOverflow](http://stackoverflow.com/questions/14474223/utf-8-not-encoding-html-in-webview-android)).\r\n\r\nAs I don't have a battery of devices/tests I don't feel comfortable sending a PR removing this.\r\n\r\n### Imho what needs to be done is:\r\n\r\n1) Remove the `; charset=utf-8`\r\n2) Run tests to see that UTF-8 characters (such as ÅÄÖ) are still displayed in all devices from API 17 up to todays number\r\n  * when given a HTML **string**.\r\n  * when given a the URI to a **local HTML file** inside the {N} app\r\n  * when given a the URI to a **web page on the internet** (such as [https://en.wikipedia.org/wiki/Ö](https://en.wikipedia.org/wiki/%C3%96) )\r\n"}}