Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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,

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 drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2016-10-23 06:20 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (300 votes). Check out past polls.