Dan Kogai wrote:
Make sure:
* You have saved your script in UTF-8, not Latin1 * use utf8 to make sure string literals are treated as UTF-8 strings * if you print, set filehandle layer to ":utf8".
Try the sript below (be sure to save it in UTF-8). I got "KÃThe => kÃthe".
# use strict; use utf8; my $fname = 'KÃThe'; my $lc_fname = lc($fname); binmode STDOUT => ":utf8"; print "$fname => $lc_fname\n"; __END__
Or, if you want to keep your script in the Latin1 encoding and also want the output printed in Latin1 instead of UTF-8, I would use
use strict; use Encode (); my $fname = 'KÃThe'; $fname = Encode::decode('iso-8859-1', $fname, Encode::FB_XMLCREF); my $lc_fname = lc($fname); binmode STDOUT => ":encoding(iso-8859-1)"; print "$fname => $lc_fname\n"; __END__
Is there any advantage in saving the script in UTF-8?
rob.