# set text $text = q~\u2018Jihadism\u2019~; # replace \uXYZ with html entity &#xXYZ; $text =~ s/\\u(\d+)/&#x$1;/g; # print text with html entities say $text;