1

perl -pe 's/A/ā/' <<< "avatAr" gives me avatār as expected.

But both perl -pe 'y/A/ā/' <<< "avatAr" and perl -pe 'tr/A/ā/' <<< "avatAr" give me avat�r.

Why is this so? And how might I get the same results as the substitution?

I also tried perl -Mutf8 -C24 -pe 'tr/A/ā/' <<< "avatAr" and it gave me

Wide character in print at -e line 1, <> line 1.
avatār

What am I doing wrong to get this warning? Identical results for y instead of tr.

chandra
  • 292
  • 2
  • 11

1 Answers1

2

In addition to needing -Mutf8 as kaavannan has explained, you are getting the 'wide character' warning because the numbers in -C24 are numbers, not flags, so that should have been written as -C6. Even better would be to use a flag and enable stderr too: -CS.

Dave Mitchell
  • 2,193
  • 1
  • 6
  • 7