html_unescape
一個用於解碼HTML的小型函數庫。支援所有名稱字元參考、十進位字元參考和十六進位字元參考。
用於解碼 HTML 編碼字串的 Dart 庫
以下為英文專案原文快照,最新內容請造訪 GitHub。
A Dart library for unescaping HTML-encoded strings.
Supports:
)
á)ã)The idea is that while you seldom need encoding to such a level (most of the
time, all you need to escape is <, >, /, & and "), you do want to
make sure that you cover the whole spectrum when decoding from HTML-escaped
strings.
Inspired by Java's unbescape library.
A simple usage example:
import 'package:html_unescape/html_unescape.dart';
main() {
var unescape = HtmlUnescape();
var text = unescape.convert("<strong>This "escaped" string");
print(text);
}
You can also use the converter to transform a stream. For example, the code
below will transform a POSIX stdin into an HTML-unencoded stdout.
await stdin
.transform(Utf8Decoder())
.transform(HtmlUnescape())
.transform(Utf8Encoder())
.pipe(stdout);
If you're sure you will only encounter the most common escaped characters,
you can import 'package:html_unescape/html_unescape_small.dart' instead of
the full version. This will decrease code size and increase performance. The
only difference is in the size of the Named Character Reference dictionary.
The full set includes the likes of ⥐ or ⤒
while the small set only includes the first 255 charcodes.
Please use GitHub tracker. Don't hesitate to create pull requests, too.