Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I need to convert a list of words to uppercase. The list contains French characters. It is encoded in latin-1 (emacs displays a "1" in the lower left corner), "locale -a" lists fr_FR.ISO8859-15 as being installed, I'm using
use POSIX qw(locale_h); setlocale(LC_CTYPE, "fr_FR.ISO8859-15");
and I've also set the locale in the shell with
export LC_CTYPE="fr_FR.ISO8859-15"
Still the French characters are not converted to uppercase. What am I missing? Can anyone give me tips what else I can do/what documentation to read beyond perllocale? I'd be very grateful, as this is quite urgent (deadline this evening).

Replies are listed 'Best First'.
Re: uc and locale problem
by Anonyrnous Monk (Hermit) on Feb 01, 2011 at 13:37 UTC
    Can anyone give me tips what else I can do
    #!/usr/bin/perl -wl use strict; use Encode; my $isolatin = "éèê"; my $unicode = decode('ISO8859-15', $isolatin); my $upper = uc $unicode; print $upper; # ÉÈÊ
Re: uc and locale problem
by Utilitarian (Vicar) on Feb 01, 2011 at 13:50 UTC
    perllocale does mention the fact that it ignores the external locale unless set in the script.
    use locale; use POSIX qw(locale_h); setlocale("LC_ALL", "fr_FR.ISO8859-1"); print uc("â, ê, î, ô, û\në, ï, ü\nà, è, ù\nç\næ\nécriture complis\n"); +' ... Â, Ê, Î, Ô, Û Ë, Ï, Ü À, È, Ù Ç Æ ÉCRITURE COMPLIS
    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: uc and locale problem
by ikegami (Patriarch) on Feb 01, 2011 at 16:20 UTC

    Note that a lot of systems have very broken locales, so the solution that avoids them would be best.

    latin-1 is iso-8859-1, not -15.