1HTML::Entities::NumbereUds(e3r)Contributed Perl DocumentHaTtMiLo:n:Entities::Numbered(3)
2
3
4
6 HTML::Entities::Numbered - Conversion of numbered HTML entities
7
9 use HTML::Entities::Numbered;
10
11 $html = 'Hi Honey<b>♥</b>';
12
13 # convert named HTML entities to numbered (decimal)
14 $decimal = name2decimal($html); # Hi Honey<b>♥</b>
15
16 # to numbered (hexadecimal)
17 $hex = name2hex($html); # Hi Honey<b>♥</b>
18
19 $content = 'Copyright © Larry Wall';
20
21 # convert numbered HTML entities (decimal) to named
22 $name1 = decimal2name($content); # Copyright © Larry Wall
23
24 $content = 'Copyright © Larry Wall';
25 # convert numbered HTML entitites (hexadecimal) to named
26 $name2 = hex2name($content); # Copyright © Larry Wall
27
28 $xml = '"Give me ¥10,000" > cherie♠';
29
30 # convert named HTML entities to numbered
31 # except valid XML entities (decimal)
32 $decimal = name2decimal_xml($xml); # "Give me ¥10,000"
33 # > cherie♠
34
35 # to numbered except valid XML entities (hexdecimal)
36 $hex = name2hex_xml($xml); # "Give me ¥10,000"
37 # > cherie♠
38
40 HTML::Entities::Numbered is a content conversion filter for named HTML
41 entities (symbols, mathmetical symbols, Greek letters, Latin letters,
42 etc.). When an argument of "name2decimal()" or "name2hex()" contains
43 some nameable HTML entities, they will be replaced to numbered HTML
44 entities. And when an argument of "name2decimal_xml()" or
45 "name2hex_xml()" contains some nameable numbered HTML entities, they
46 will be replaced to numbered HTML entities except valid XML entities
47 (the excepted "valid XML entities" are the following five entities:
48 "<", ">", "&", """, "'"). By the same token, when
49 an argument of "decimal2name()" or "hex2name()" contains some nameable
50 numbered HTML entities, they will be replaced to named HTML entities.
51
52 (the exception "valid XML entities" means the following five entities:
53 "<", ">", "&", """, "'")
54
55 On version 0.03, the entities hash table is imported from
56 HTML::Entities (with obsolete class "HTML::Entities::Numbered::Extra"
57 for older releases of Perl). At the moment, 0.04 (or later) is
58 included HTML::Entities::Numbered::Table to import HTML entities table,
59 and thereby we do not need to have HTML::Entities (included in
60 HTML::Parser distribution).
61
62 This may be also useful for making valid XML (corrects the undefined
63 entity references, and enhanced by addition of functions conform to the
64 XML).
65
67 Following all functions are exported by default.
68
69 · name2decimal
70
71 Some included named HTML entities in argument of "name2decimal()"
72 will be replaced to decimal numbered HTML entities.
73
74 · name2hex
75
76 Some included named HTML entities in argument of "name2hex()" will
77 be replaced to hexadecimal numbered HTML entities.
78
79 · decimal2name
80
81 Some include decimal numbered HTML entities in argument of
82 "decimal2name()" will be replaced to named HTML entities (If
83 they're nameable).
84
85 · hex2name
86
87 Some include hexadecimal numbered HTML entities in argument of
88 "hex2name()" will be replaced to named HTML entities (If they're
89 nameable).
90
91 · name2decimal_xml
92
93 Some included named HTML entities in argument of
94 "name2decimal_xml()" will be replaced to decimal numbered HTML
95 entities except valid XML entities.
96
97 · name2hex_xml
98
99 Some included named HTML entities in argument of "name2hex_xml()"
100 will be replaced to hexadecimal numbered HTML entities except valid
101 XML entities.
102
103 If you'd prefer not to import them functions into the caller's
104 namespace, you can call them as below:
105
106 use HTML::Entities::Numbered ();
107
108 $decimal = HTML::Entities::Numbered::name2decimal($str);
109 $hex = HTML::Entities::Numbered::name2hex($str);
110 $named1 = HTML::Entities::Numbered::decimal2name($str);
111 $named2 = HTML::Entities::Numbered::hex2name($str);
112 $decimal = HTML::Entities::Numbered::name2decimal_xml($str);
113 $hex = HTML::Entities::Numbered::name2hex_xml($str);
114
116 Koichi Taniguchi <taniguchi@livedoor.jp>
117
118 Develop triggered by IKEBE Tomohiro <ikebe@cpan.org>
119
120 Many thanks to Tatsuhiko Miyagawa <miyagawa@cpan.org>
121
123 Copyright (c) 2004 Koichi Taniguchi. Japan. All rights reserved.
124
125 This library is free software; you can redistribute it and/or modify it
126 under the same terms as Perl itself.
127
129 HTML::Entities, <http://www.w3.org/TR/REC-html40/sgml/entities.html>
130
131
132
133perl v5.28.0 2004-09-02 HTML::Entities::Numbered(3)