📄 entities.pm
字号:
package HTML::Entities;# $Id: Entities.pm,v 1.1 1999/07/21 19:12:25 kraven Exp $=head1 NAMEHTML::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");=head1 DESCRIPTIONThis module deals with encoding and decoding of strings with HTMLcharacter entites. The module provide the following functions:=over 4=item decode_entities($string)This routine replaces HTML entities found in the $string with thecorresponding ISO-8859/1 character. Unrecognized entities are leftalone.=item endode_entities($string, [$unsafe_chars])This routine replaces unsafe characters in $string with their entityrepresentation. A second argument can be given to specify whichcharacters to concider as unsafe. The default set of characters toexpand are control chars, high-bit chars and the '<', '&', '>' and '"'character.=backBoth routines modify the string passed in as the first argument ifcalled in void context. In scalar and array context the encoded ordecoded string is returned (and the argument string is leftunchanged).If you prefer not to import these routines into your namespace you cancall them as: use HTML::Entities (); $encoded = HTML::Entities::encode($a); $decoded = HTML::Entities::decode($a);The module can also export the %char2entity and the %entity2charhashes which contains the mapping from all characters to thecorresponding entities.=head1 COPYRIGHTCopyright 1995-1998 Gisle Aas. All rights reserved.This library is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.=cutuse strict;use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);use vars qw(%entity2char %char2entity);require 5.004;require Exporter;@ISA = qw(Exporter);@EXPORT = qw(encode_entities decode_entities);@EXPORT_OK = qw(%entity2char %char2entity);$VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);sub Version { $VERSION; }%entity2char = ( # Some normal chars that have special meaning in SGML context amp => '&', # ampersand 'gt' => '>', # greater than'lt' => '<', # less than quot => '"', # double quote # PUBLIC ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML AElig => '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -