package HTML::Entities;
# $Id: Entities.pm,v 1.27 2003/10/10 09:56:18 gisle Exp $
=head1 NAME
HTML::Entities - Encode or decode strings with HTML entities
=head1 SYNOPSIS
use HTML::Entities;
$a = "Våre norske tegn bør æres";
decode_entities($a);
encode_entities($a, "\200-\377");
For example, this:
$input = "vis-à-vis Beyoncé's naïve\npapier-mâché résumé";
print encode_entities($in), "\n"
Prints this out:
vis-à-vis Beyoncé's naïve
papier-mâché résumé
=head1 DESCRIPTION
This module deals with encoding and decoding of strings with HTML
character entities. The module provides the following functions:
=over 4
=item decode_entities( $string )
This routine replaces HTML entities found in the $string with the
corresponding ISO-8859-1 character, and if possible (under perl 5.8
or later) will replace to Unicode characters. Unrecognized
entities are left alone.
This routine is exported by default.
=item encode_entities( $string )
=item encode_entities( $string, $unsafe_chars )
This routine replaces unsafe characters in $string with their entity
representation. A second argument can be given to specify which
characters to consider unsafe (i.e., which to escape). The default set
of characters to encode are control chars, high-bit chars, and the
C<< < >>, C<< & >>, C<< > >>, and C<< " >>
characters. But this, for example, would encode I the
C<< < >>, C<< & >>, C<< > >>, and C<< " >> characters:
$escaped = encode_entities($input, '<>&"');
This routine is exported by default.
=item encode_entities_numeric( $string )
=item encode_entities_numeric( $string, $unsafe_chars )
This routine works just like encode_entities, except that the replacement
entities are always C<I;> and never C<&I;>. For
example, C returns "rôle", but
C returns "rôle".
This routine is I exported by default. But you can always
export it with C