Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encoding All Entities

Status
Not open for further replies.

Aarem

Programmer
Oct 11, 2004
69
US
Hi. I looked into HTML::Entities in CPAN, and I was wondering how you can encode every letter into an html entity. In tried the following, but it doesn't work!

Code:
use HTML::Entities;
encode_entities_numeric( "hi, this is my message.  Why does perl not encode this?", /./ )
 
If you are trying to output the results then you need to..

Code:
use HTML::Entities;
[b]print[/b] encode_entities_numeric( "hi, this is my message.  Why does perl not encode this?", /./ );

 
I know this; my problem is that perl outputs it the same way as inputted.
 
As far as I can see from the splurge on CPAN, HTML::Entities is not designed to encode every number/letter into an HTML entity. It is only designed to deal with any characters that aren't [0-9A-Za-z].

Also, encode_entities_numeric() isn't exported as standard in perl so try using:
Code:
use HTML::Entities qw(encode_entities_numeric);
$a = 'hi, this is my message.  Why does perl not encode this?';
$encoded = HTML::Entities::encode_numeric($a);
print $encoded."\n";


Rob Waite
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top