F
F
foonfyrick2021-03-27 09:52:43
Android
foonfyrick, 2021-03-27 09:52:43

Why doesn't webView.loadData always display all characters?

With this option, all characters are displayed on the webView.

webview.webViewClient = WebViewClient()
val text = "<html><body><h1>[email protected]#$%^&*()-=_+</h1></body></html>"
val webData = text.replace("#", "0")
webview.loadData(webData,"text/html","en_US")

If you change "#" to any other character in the line val webData = text.replace("#", "0"), then only "!" and "@"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-03-27
@NeiroNx

Because these are HTML utility characters
Use TextUtils.htmlEncode to convert special characters to their HTML codes

val text = "<html><body><h1>"+TextUtils.htmlEncode("[email protected]#$%^&*()-=_+")+"</h1></body></html>"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question