- or download this
$string =~ s/([^a-zA-Z0-9])/'&#'.unpack('U0U*',$1).';'/eg;
- or download this
use HTML::Entites qw( encode_entities );
$string = encode_entities($string);
- or download this
use Encode qw( encode );
$string = encode('US-ASCII', $string, Encode::FB_HTMLCREF);
- or download this
use Encode qw( from_to );
...
from_to($string, 'UTF-8', 'US-ASCII', Encode::FB_HTMLCREF);
return($string);
}