P.Henderson P.Henderson - 1 year ago 82
Perl Question

Perl HTML Encoding Named Entities

I would like to encode 'special chars' to their named entity.

My code:

use HTML::Entities;
print encode_entities('“');

Desired output:


And not:


Does anyone have an idea? Greetings


Perl doesn't know the encoding of your source file. If you include any special characters, you should always save it with UTF-8-encoding and put

use utf8;

at the top of your code. This will make sure your string literals contain codepoints, not just bytes.