in reply to Encode only wide char entities?

You read the docs, right? :P HTML::Entities.

and this would only encode non-plain ascii: $encoded = encode_entities($input, '^\n\x20-\x25\x27-\x7e');