in reply to A Perl/CGI alternative to PHP's htmlentities()?

Have you considered HTML::Entities? Something similar to the following will work if I understand what you want:

use HTML::Entities; my $html = "bad stuff here"; $html = encode_entities($html, "\x80-\xff");