Get rid of the locale stuff, and tell Perl what your input and (desired) output encodings are:
#!/usr/bin/perl -w use strict; use feature qw( :5.10 ); use Carp; my $file = q{./yard}; open my $IN, '<:encoding(ISO8859-1)', $file or croak; binmode STDOUT, ":utf8"; # assuming your terminal is UTF-8 while (my $l = <$IN>) { # $l is now a Unicode/text string chomp $l; say "1: $l"; say "2: ", xlc($l); } ... sub xlc as you have it
Output:
1: CLÉ USB 2: Clé Usb 1: CLÉMMY USB 2: Clémmy Usb
Using the PerlIO layer ":encoding(ISO8859-1)" with open tells Perl that your input is in ISO8859-1, and has the effect of decoding the data into Perl's internal Unicode format, so ucfirst etc. will work correctly.
The general idea is to decode on input, and encode on output. Perl will then (ideally) do the rest.
In reply to Re: Unable to lc upper case accented characters
by Eliya
in thread Unable to lc upper case accented characters
by jkeenan1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |