http://www.perlmonks.org?node_id=620873


in reply to Re^2: strip html tags and special characters in perl while inserting the text in to database.
in thread strip html tags and special characters in perl while inserting the text in to database.

I want the corresponding special character for the $resume variable.

I don't understand what that means. Can you explain more carefully what you really want? Also, can you please try to be more clear about what is being assigned as the value of $resume?

It actually seems that you are assigning a three-byte value:  "\xE2\x80\x9D" -- this happens to be interpretable as the utf8 encoding for the unicode character U+201D "RIGHT DOUBLE QUOTATION MARK". Do you want to replace this with the ASCII double-quote character?

my $resume = "\x{201D}"; print "$resume\n"; $resume =~ s/\x{201d}/"/g; print "$resume\n";
(updated to make sure the s/// applies to the value of $resume)

To do that sort of replacement in a "general" sense (i.e. replace all "wide-character" versions of punctuation marks with ASCII versions of same wherever possible), you probably want Text::Unidecode:

#!/usr/bin/perl use strict; use Text::Unidecode; my $resume = "\x{201d}"; print unidecode( $resume ), "\n";