Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Lowercasing umlauts in words

by Anonymous Monk
on Jun 10, 2004 at 18:50 UTC ( #363156=perlquestion: print w/replies, xml ) Need Help??

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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://363156]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2020-07-16 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?