更新时间:2023-02-23 12:46:09
Html.fromHtml(str).toString();
应该可以.我告诉你原因-
Html.fromHtml(str).toString();
should work. I tell you the reason -
您的字符串是Html
. Unicode字符存储为编码的字符实体. &#x
;符号用于转义unicode字符,以便通过ISO-8859-1进行传输. 网络浏览器会对它们进行解码以显示实际的unicode字符.
Your string is Html
. Unicode characters are stored as encoded character entities. The &#x
; notation is used to escape unicode characters for transmission over ISO-8859-1. A web browser decodes them to display actual unicode characters.
解码HTML就是将HTML实体解码为Java原始unicode字符.
Decoding HTML is decoding HTML entities to Java raw unicode characters.
例如:
String html = "B & This is HTML";
String java = Html.fromHtml(html);
#=> Output: "B \u0026 This is HTML"
String strJava = Html.fromHtml(html).toString();
#=> Output: "B & This is HTML"