Android webview does not display the% symbol

I have WebViewusing the following code:

WebView webView = new WebView(cont);
webView.loadData("Red 20%", "text/html", "utf-8");

The problem has a line. But if I remove the '%' character from the string that displays correctly. What is wrong with the code? How to display "%" in WebView?

+3
source share
5 answers

Plain:

WebView webView = new WebView(cont);
webView.loadData("Red 20%", "text/html", "utf-8");

You can see special characters here: http://www.degraeve.com/reference/specialcharacters.php

+3
source

URL encodes%

20% 25 must do the trick

+1
source

TextUtils.htmlEncode() , .

WebView webView = new WebView(cont);
String s = TextUtils.htmlEncode("Red 20%");
webView.loadData(s, "text/html", "utf-8");
0

% equevalent, . %,

webView.loadData("Red 20%", "text/html", "utf-8"); 
0

You can replace "Red 20%" → "Red 20%"

0
source

All Articles