pc88mxer has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to use HTML::Entities to encode only characters >= 256? That is, I want to perform:
$text =~ s{([^\0-\377])}{'&#'.ord($1).';'}ge;
but I want to use HTML::Entities to do it. Is this possible?

Replies are listed 'Best First'.
Re: use HTML::Entities to encode only characters >= 256?
by ikegami (Patriarch) on Nov 02, 2007 at 16:07 UTC
    encode_entities(encode_entities($text, q{<>&"'}), '^\0-\377')

    Update: Oops, changed 0 to \0.

      Thanks for the reply! I didn't realize that you could specify negation in the second parameter to encode_entities().

      The HTML::Entities documentation should make it clearer that the second argument is just wrapped in square brackets and treated as a regular expression.