Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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.

So.
& 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,
Wonko

Comment on Converting HTML Entities to thier numeric equivalent
Select or Download Code
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.
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,
      Wonko

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-09-23 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (219 votes), past polls