이름 지정된, 십진수 및 16진수 문자 참조를 포함한 HTML 엔티티를 디코딩하기 위한 가벼운 Flutter/Dart 패키지입니다. 안전하게 이스케이프된 HTML 텍스트를 원래 형태로 변환하여 웹 소스나 사용자 입력에서 콘텐츠를 렌더링하는 데 이상적입니다. 이 라이브러리는 효율적이고 최소한의 크기이며, 여러 플랫폼에서 Dart 애플리케이션에 특별히 설계되었습니다.
사용 사례
UI에서 HTML 인코딩된 텍스트 렌더링
사용자 생성 콘텐츠 처리
웹 API에서 데이터 파싱하기
CMS에서 형식화된 텍스트 표시
표시 전에 입력을 정제하기
주요 기능
모든 HTML 엔티티 유형을 지원합니다
경량이고 빠름
크로스 플랫폼 호환성
간단한 API, 명확한 메서드
외부 종속성 없음
적합한 대상
원시 HTML 문자열을 처리하는 앱
콘텐츠 렌더링 앱
웹 스크래핑 유틸리티
텍스트 처리 도구
교육용 또는 문서 앱
고려 사항
완전한 HTML 문서를 파싱하지 않습니다
XSS 보호에 적합하지 않습니다
미이스케이프된 콘텐츠에 대한 수동 정제가 필요합니다
문자 참조 디코딩에 제한됨
복잡한 HTML 조작을 위한 것이 아님
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
html_unescape
A Dart library for unescaping HTML-encoded strings.
Supports:
Named Character References ( )
2099 of them
Decimal Character References (á)
Hexadecimal Character References (ã)
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.
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.
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.