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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.