ppant has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am using HTML::Entities module to encode some special chars. Here is my code:

use HTML::Entities qw(encode_entities_numeric); my $str = "some special chars like € ™ © ®"; encode_entities_numeric($str); print $str; Output: € ™ © ®
As output is in hex num of the char. I want output in form of HTML numeric decimal value of the chars like  € ™ © ®

Is there a way to do this in encode_entities_numeric()


Thanks!

Replies are listed 'Best First'.
Re: Covert to decimal HTML code in encode_entities_numeric
by neilwatson (Priest) on Dec 02, 2015 at 13:20 UTC
      Thanks. Will have a look.
Re: Covert to decimal HTML code in encode_entities_numeric
by toolic (Bishop) on Dec 02, 2015 at 13:17 UTC
    I don't know if encode_entities_numeric() can do it, but if it can't, here is a way to post-process the results:
    use warnings; use strict; my $str = "some special chars like € ™ © ®"; $str =~ s/&#x([[:xdigit:]]+)/'&#' . hex($1)/eg; print "$str\n"; __END__ some special chars like € ™ © ®
      Thanks.