I receive files with human names in ALL CAPS, including accented upper case characters. The files are in iso-8859-1.

CLÉ USB CLÉMMY USB

I need to "proper-case" these words, i.e., Initial Cap All Other Characters Lower Case.

When I open these files in vi, I don't see the upper-case accented E; I see a question-mark.

CL? USB CL?MMY USB
But when I run these lines through Encode::from_to, I do get the upper case accented E. But no matter what I do, I can't seem to lower-case that upper-case accented E. In fact, the succeeding character remains upper-case as well.
use strict; use warnings; use feature qw( :5.10 ); use Data::Dumper;$Data::Dumper::Indent=1; use Carp; use Encode qw( from_to ); use POSIX qw( setlocale LC_CTYPE ); setlocale(LC_CTYPE, "fr_CA.ISO8859-1"); my $file = q{./yard}; open my $IN, '<', $file or croak; while (my $l = <$IN>) { chomp $l; say "1: $l"; my $m = $l; from_to($m, "iso-8859-1", "utf8"); say "2: $m"; say "3: ", xlc($m); } close $IN or croak; sub xlc { my $str = shift; return join q{} => ( map { ucfirst(lc($_)) } ( $str =~ m/(\W+|\w+) +/g ) ); };
Results:
1: CL? USB 2: CLÉ USB 3: ClÉ Usb 1: CL?MMY USB 2: CLÉMMY USB 3: ClÉMmy Usb
What am I doing wrong?

Thank you very much.

Jim Keenan

In reply to Unable to lc upper case accented characters by jkeenan1

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.