http://www.perlmonks.org?node_id=363156

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

Hello Monks!

I'm trying to set words in a mixed case format. The cpan NameCase module seems interesting but it doesn't seem to handle german umlauts. I'm wondering if there is another way. When I use perl's lc on it. Most of the word is lowercased except for the umlaut. Any tips?

#!/usr/local/bin/perl -w use strict; use Lingua::EN::NameCase 'nc'; print nc("BAESCHGÄSSEL") . "\n"; #not ok print lc("BAESCHGÄSSEL") . "\n"; #Better uppercase umlaut
The output is:

BAESCHGÄSSEL

baeschgÄssel

Replies are listed 'Best First'.
Re: Lowercasing umlauts in words
by haoess (Curate) on Jun 10, 2004 at 19:48 UTC

    From perllocale:

    By default, Perl ignores the current locale. The "use locale" pragma tells Perl to use the current locale for some operations: [ ... ] lc().
    $ perl -le 'print lc "ÄÖÜ";' ÄÖÜ $ echo $LC_ALL de_DE $ perl -Mlocale -le 'print lc "ÄÖÜ";' äöü

    You can switch the current locale in your perl program reading locale or perllocale.

    And BTW: lc is the same as "\L".

    -- Frank

Re: Lowercasing umlauts in words
by the_slycer (Chaplain) on Jun 10, 2004 at 19:34 UTC
    I had the same issue a while back with french characters.

    The answer is the locale pragma:

    use locale; print lc("BAESCHGÄSSEL") . "\n";
    Output: baeschgässel
Re: Lowercasing umlauts in words
by roju (Friar) on Jun 10, 2004 at 19:27 UTC
    I had success using a regular expression.

    perl -pe 's/(.*)/\L\1/' worked no problem.

Re: Lowercasing umlauts in words
by Anonymous Monk on Jun 10, 2004 at 21:09 UTC
    Upgrading to version 5.8 fixed this. I was using version 5.6. Thanks everyone!