Kotlin : how to Convert String with HTML numbers to String without HTML numbers

mhKarami :

I am trying to convert all HTML numbers in a string. I want to convert a String like "Let's find" to "Let's find"in Kotlin

i tested these but not worked:

str.toByteArray().toString(Charsets.UTF_8)

Chrisvin Jem :

As suggested by second in the comments, you need to parse the html string using Html.fromHtml and then get the string value from it.

var str:String = "Let's find"
str = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Html.fromHtml(str, Html.FROM_HTML_MODE_LEGACY).toString() 
        } else {
            Html.fromHtml(str).toString() 
        }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=125467&siteId=1