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