http://qs321.pair.com?node_id=558830


in reply to zapping gremlins

I suspect that the data is coming from MS Word, which loves to use custom quote and dash symbols.

If you copy the character and run something like this:

perl -e 'print ord(shift) . "\n"' "’"

You should get 226.
But if you iterate over the list of characters sent in the actual form data it will be something different. (decimal 146, hex 92)

You could match this with \x92

$in{'content'} =~ s/\x92/’/g;
I do the following for msword character stripping:
# Somewhere in an init function I define the hex value => string mappi +ng # I find it easier to edit this way my %seed = ( '82' => ',', '83' => '<em>f</em>', '84' => ',,', '85' => '...', '88' => '^', '89' => ' °/°°', '8B' => '<', '8C' => 'Oe', '91' => '`', '92' => '\'', '93' => '"', '94' => '"', '95' => '*', '96' => '-', '97' => '--', '98' => '<sup>~</sup>', '99' => '<sup>TM</sup>', '9B' => '>', '9C' => 'oe', ); # Build a mapping of the hex code to string lookup table. # I find it to be less error prone than maintaining it manually my %msword_replace = (); while (my ($hex, $replace_with) = each %seed) { $msword_replace{chr(hex($hex))} = $replace_with; } # Define a list of hex codes that will be used as the search patte +rn # Then create a regex with alternation for these codes my @hex_codes = map {'\x' . $_} keys %seed; $msword_re = sprintf "(%s)", join('|', @hex_codes); # And then later when I need to do the replacing: $data =~ s/$msword_re/$msword_replace{$1}/g;
There is probably a commonly used module for doing this, but hope this example helps.