#!/usr/bin/perl -- use strict; use warnings; use utf8; use HTML::Entities; binmode STDOUT, ':encoding(UTF-8)'; { my $line = "This is a test of \xe2\x80\x9cquotes\xe2\x80\x9d\n"; print encode_entities($line, "\200-\377"); # looking for “ ” in the output print $line; } print '#' x 11, "\n"; { my $line = 'xThis is a test of '.chr(8220).'quotes'.chr(8222)."\n"; print encode_entities($line, '\x{201c}\x{201e}'); print $line; } print '#' x 11, "\n"; { my $line = 'xThis is a test of '.chr(8220).'quotes'.chr(8222)."\n"; print encode_entities($line, chr(8220).chr(8222)); print $line; } __END__ This is a test of “quotes” This is a test of “quotes” ########### xThis is a test of “quotes„ xThis is a test of “quotes„ ########### xThis is a test of “quotes„ xThis is a test of “quotes„