in reply to replace special character with its unicode
or$data =~ s{ ([^\w\s\xA0~!@#$%^&*\-_=+()[\]{}|;:'`",<.>/?\xA9\xA7]) }{ sprintf "{U+%04X}", ord($1) }xeg;
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.
|
|---|