Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2018-06-20 23:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.