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