Search code examples
androidhtmlhtml-encode

Overcome unnecessary characters in html string in Android?


in RSS FEED. I am doing like this to supress html characters from string

public void setEncodedContent(String encodedContent) {
    //this.encodedContent = encodedContent;
    String noHTMLString = encodedContent.replaceAll("\\<.*?>","");
    this.encodedContent = noHTMLString;
}

But I am receiving characters like

&#8211 &#8217 &#8221

What is the way to overcome it ?

Regards


Solution

  • This worked for me. Hope will be helpful to readers

    public void setEncodedContent(String encodedContent) {
    //this.encodedContent = encodedContent;
    String noHTMLString = encodedContent.replaceAll("\\<.*?>","");
    String yesHTMLString= Html.fromHtml(noHTMLString).toString();
    this.encodedContent = yesHTMLString;
    
    }