我正在尝试将所有 HTML 数字
转换为一个字符串。
我想在 Kotlin
"Let's find"
之类的字符串转换为 "Let's find"
我测试了这些但没有用:
str.toByteArray().toString(Charsets.UTF_8)
最佳答案
正如评论中第二个建议的那样,您需要使用 Html.fromHtml
解析 html 字符串,然后从中获取字符串值。
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()
}
关于java - Kotlin : how to Convert String with HTML numbers to String without HTML numbers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57194820/