HTML::Entity::Fast - Encode / Decode HTML entities faster
use HTML::Entity::Fast;
say encode-html-entities '<ent> & ©'; # <ent> & ©
say decode-html-entities '<ent> & ©'; # <ent> & ©
my $w-encode = whitelist-in-encode("<",">");
say encode-html-entities '<ent> & ©', $w-encode; # <ent> & ©
my $w-decode = whitelist-in-decode('&');
say decode-html-entities '<ent> & ©', $w-decode; # <ent> & ©
HTML::Entity::Fast provides subroutines for encoding and decoding HTML entities in a string.
say encode-html-entities '<ent> & ©'; # <ent> & ©
my $w-encode = whitelist-in-encode("<",">");
say encode-html-entities '<ent> & ©', $w-encode; # <ent> & ©
Encode any special characters in a given string to their HTML entity counterpart. Optionally takes a second argument indicating the exact mapping to be used (which is usually the result of a call to the whitelist-in-encode
subroutine).
say decode-html-entities '<ent> & ©'; # <ent> & ©
my $w-decode = whitelist-in-decode('&');
say decode-html-entities '<ent> & ©', $w-decode; # <ent> & ©
Decode any HTML entities in a given string to their Unicode counterpart. Optionally takes a second argument indicatig the exact mapping to be used (which is usually the result of a call to the whitelist-in-decode
subroutine).
my $w-encode = whitelist-in-encode("<",">");
The whitelist-in-encode
subroutine takes any number of arguments, each indicating a character that should not be converted by the encode-html-entities
subroutine. It returns a lookup map that can be specified as the second positional argument to encode-html-entities
.
my $w-decode = whitelist-in-decode('&');
The whitelist-in-decode
subroutine takes any number of arguments, each indicating a HTML entity that should not be converted by the decode-html-entities
subroutine. It returns a lookup map that can be specified as the second positional argument to decode-html-entities
.
Elizabeth Mattijsen liz@raku.rocks
Source can be located at: https://github.com/lizmat/HTML-Entity-Fast . Comments and Pull Requests are welcome.
If you like this module, or what I’m doing more generally, committing to a small sponsorship would mean a great deal to me!
Copyright 2022, 2024 Elizabeth Mattijsen
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.