Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Converting HTML Entities to thier numeric equivalent

by Wonko the sane (Deacon)
on Dec 09, 2004 at 20:29 UTC ( #413676=perlquestion: print w/ replies, xml ) Need Help??
Wonko the sane has asked for the wisdom of the Perl Monks concerning the following question:

I am looking for an easy way to convert HTML entities, like
´   &
into thier numeric representations.

& would be converted to &
¡ would be converted to ¡

and so on.

I need this to work for ALL of the HTML entities. I am trying to get out of writting
a search and replace regex for all 255 of the different HTML entities like this. :)

I find it hard to believe that there is not a module already out ther that can do this for me.

Any help or pointer on solving this problem would be much appreciated.

Best Regards,

Comment on Converting HTML Entities to thier numeric equivalent
Select or Download Code
Replies are listed 'Best First'.
Re: Converting HTML Entities to thier numeric equivalent
by Ovid (Cardinal) on Dec 09, 2004 at 20:48 UTC
      Perfect! Thank you very much. Just what I needed.

      Best Regards,

Re: Converting HTML Entities to their numeric equivalent
by Roy Johnson (Monsignor) on Dec 09, 2004 at 20:35 UTC
    Browsing the source of HTML::Encoder, I find a table that provides the reverse mapping of what you're looking for -- sort of. It could be helpful.

    Update: Hold the phone! I found it: HTML::Entities::Numbered provides conversions between numbered and named entities.

    Caution: Contents may have been coded under pressure.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://413676]
Approved by johnnywang
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2015-11-29 02:14 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (746 votes), past polls