是否有一个更快的方法去code HTML字符的字符串比Html.fromHtml()?更快、字符串、有一个、字符

2023-09-12 07:16:24 作者:公子薄情

我使用Html.fromHtml(串)的ToString()转换,可能会或可能不会有HTML和/或HTML实体中有一个字符串,以纯文本字符串。

I am using Html.fromHtml(STRING).toString() to convert a string that may or may not have html and/or html entities in it, to a plain text string.

这是pretty的慢,我觉得我最后的计算是,它花了大约22毫秒的魅力。随着大批量的这些,可加一分多钟。所以,我在找一个更快,性能内置选项。

This is pretty slow, I think my last calculation was that it took about 22ms on avg. With a large batch of these it can add over a minute. So I am looking for a faster, performance built option.

反正是有加快这还是有其他可用的解码方案?

Is there anyway to speed this up or are there other decoding options available?

编辑:因为似乎没有被内置的是更快,性能卓越具体的方法,我会奖励赏金给任何人,可以在一个图书馆的方向指向我即:

Since there doesn't appear to be a built in method that is faster or built for performance specifically, I will reward the bounty to anyone that can point me in the direction of a library that:

与Android 工作以及 授权免费使用 速度比 Html.fromHtml(串)的ToString(); Works well with Android Licensed for free use Faster than Html.fromHtml(String).toString();

作为一个说明,我已经尝试过Jsoup用这种方法: Jsoup.parse(串)的.text(),它是慢

As a note, I already tried Jsoup with this method: Jsoup.parse(String).text() and it was slower.

推荐答案

怎么样org.apache.commons.lang.StringEscapeUtils的unescapeHtml().该库可在阿帕奇网站。

What about org.apache.commons.lang.StringEscapeUtils's unescapeHtml(). The library is available on Apache site.