Been trying to remove a right single quotation mark from data coming into a Perl form unsuccessfully. If I paste the text: ( Can’t Be Dodged ) into the form it never removes the right single quotation mark. I've tried different methods of encoding and escaping the Unicode and nothing seems to work.
Below is what I'm working with.
#!/usr/bin/perl
use strict;
use CGI::Carp qw( fatalsToBrowser carpout);
use CGI '-utf8';
my $q = CGI->new;
my $buffer = $q->param( 'q' );
print "Content-Type: text/html; charset=UTF-8", "\n\n";
$buffer =~ s/[\'\`\.]//g;
$buffer =~ s/’//sg;
print "$buffer";
So, the trick is to figure out what the character is. One solution is to do something like this:
for my $c (split //, $buffer) {
printf "[$c]: %x\n", ord $c;
}
Once you know what the character is, removing it is simple.