in reply to Re^2: Playing with "funny" chars
in thread Playing with extended chars

I think the problem is not on the string (I'm using perl5.8.5, because 5.8.0 had some bugs in RedHat), but on the tr operator itself.

The first attemp works like this:

perl -e '$_="áéíóú";tr/áéíóú/aeiou/;print' aeaoauauau
It seems that "á" is treated as two characters, maybe "´" and "a", and each one get one different matching char ( "a" and "e").

BTW, encode and decode functions return values that make me think that the string is well formed, and that is tr// who's making wrong things. Am I too lost?

Replies are listed 'Best First'.
Re^4: Playing with "funny" chars
by itub (Priest) on Sep 27, 2004 at 15:42 UTC
    If you have utf8 encoded strings in your program file, you need to use the utf8 pragma (see perldoc utf8).

    use utf8; $s = 'holáéíóúon'; $s =~ tr/áéíóú/aeiou/; print $s; # prints holaeiouon
    The code above may show the double characters explicitly since perlmonks.org is served as ISO-8859-1.