In a perl string, how can I replace a unicode em dash with 2 ascii hyphens? -
i first tried find in line using:
$w = index($line, "\x{2014}"); i got no syntax error, $w never >= 0.
i tried:
$line =~ s/\x{2014}/--/g; and didn't work either, ie: no changes made.
what's simplest way make swap?
if explained in prior posts, didn't see where.
works me:
#!/bin/perl -w use feature 'unicode_strings'; use utf8; $line = "first — , second"; $line =~ s/\x{2014}/--/g; print("$line\n"); # => first -- , second
Comments
Post a Comment