in reply to replace special character with its unicode

$data =~ s{ ([^\w\s\xA0~!@#$%^&*\-_=+()[\]{}|;:'`",<.>/?\xA9\xA7]) }{ sprintf "{U+%04X}", ord($1) }xeg;
or
use charnames qw( :full ); $data =~ s{ ([^\w\s\xA0~!@#$%^&*\-_=+()[\]{}|;:'`",<.>/?\N{COPYRIGHT SIGN}\N{SE +CTION SIGN}]) }{ sprintf "{U+%04X}", ord($1) }xeg;

It seems to me that \w and \s match way more than you want, though.