use HTML::Entities; use Text::Iconv; my $text = chr(256); my $conv = Text::Iconv->new("utf8", "latin1"); $text = $conv->convert($text); encode_entities($text); print "$text\n";