As answered in the CB, use utf8::upgrade on the string.
The behaviour of some Perl ops currently depends on the internal encoding of the string. utf8::upgrade and utf8::downgrade alter the internal encoding of the string.
\u and \l are implemented in terms of uc and lc, which are susceptible to this limitation/bug.
For example,
$ perl -le'use open ":std", ":locale"; $_="\xE0 la plage"; utf8::downg +rade($_); print "\u$_"' à la plage $ perl -le'use open ":std", ":locale"; $_="\xE0 la plage"; utf8::upgra +de($_); print "\u$_"' À la plage
I've got use UTF8;
I hope you mean use utf8;, which simply tells Perl the source code that contains it is encoded using UTF-8 (not iso-latin-1). It doesn't affect IO.
I have lots of name in a UTF8 text file.
Did you decode the contents back into character? One way:
open(my $fh, '<:encoding(UTF-8)', $qfn) or die("Can't open file $qfn: $!\n");
Don't forget to encoding on the way out.
Undefined subroutine &main::setlocale called
setlocale is from POSIX. Did you actually load the POSIX module and import setlocale from it?
Update: Added example.
In reply to Re: utf8 change case on accented characters
by ikegami
in thread utf8 change case on accented characters
by JimmyMTL
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |