Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Convert HTML symbols to equivalent Unicode

by jai_dgl (Beadle)
on Apr 14, 2009 at 12:38 UTC ( [id://757380]=note: print w/replies, xml ) Need Help??


in reply to Re: Convert HTML symbols to equivalent Unicode
in thread Convert HTML symbols to equivalent Unicode

Thanks for your reply,
I spider some web pages and pull some information from them.

Then I use HTML::Entities::encode_entities() function to convert the special characters

when ® is passed to it, it is converted to ®
When HTML::Entities::encode_numeric() is used it gives ®

My final idea is to write a XML file with its Unicode equivalent(U+00AE).

Thanks
  • Comment on Re^2: Convert HTML symbols to equivalent Unicode

Replies are listed 'Best First'.
Re^3: Convert HTML symbols to equivalent Unicode
by dorward (Curate) on Apr 15, 2009 at 10:01 UTC

    I spider some web pages and pull some information from them.

    At this point you will either have the results of parsing HTML or you will have raw HTML.

    when ® is passed to it, it is converted to ®

    This suggests you are dealing with parsed HTML, with any entities already converted to real characters.

    In this case, there are two approaches you could take.

    1. Use a module designed for writing XML
    2. Use a generic template module

    If you use a module designed for writing XML then you can just pass the ® and the module will output either a raw ® or a numeric entity for it. Any XML parser that this XML gets read by should be able to cope with either, so it doesn't matter which you end up with and you don't need to worry about it.

    If you use a generic templating language, then you have to deal with using a raw ® or converting it with HTML::Entities::encode_numeric() or a similar module. Basically — you have to do all the things that a proper XML module would do for you.

    It sounds like you are using a generic templating language, but it is almost certainly better to use a real XML module.

    Afterthought: You might also be messing about with raw strings in the middle of your code. That way lies madness.

Re^3: Convert HTML symbols to equivalent Unicode
by Anonymous Monk on Feb 01, 2011 at 04:34 UTC
    Hello, I wants to numeric entities but below code will display à i need ex: © how can i get this output. my $encoded = HTML::Entities::encode_numeric($val, '^\n\x20-\x25\x27-\x7e'); Thanks, Umesh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://757380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (None)
    As of 2024-04-25 01:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found