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

Hi, Monks.

I think somebody ask this question before me but i can't find it :-( (trying Google and Perlmonks Search). So i ask you for help.

I need to capitalize (using uc) some russian text. I try this code but it does't work :-(

#!/usr/bin/perl use warnings; use strict; use locale; use POSIX qw(locale_h); my $locale = "ru_RU.CP-1251"; #Russian Windows locale (as i think) my $new_locale = setlocale(LC_ALL, $locale); die "Could't set locale" if ($new_locale ne $locale); print uc("some_string_in_russian"), "\n";

And this code dies :-(. Can you show me the right way to use all benefits of uc, lc, lcfirst, ucfirst in russian copy of Windows?

Replies are listed 'Best First'.
Re: Using locale under Windows
by moritz (Cardinal) on Dec 06, 2007 at 11:38 UTC
    I never tried it with Russian text, but with German Umlauts (ä and such).

    I didn't need any locales, but I had to convert the strings to textstrings first (using Encode::decode), do the uc, and finally encode it again (with Encode::encode) before printing the result.

    I guess this will work for any Unicode codepoints for which the behaviour of uc is not language specific.

      Thanks! It working (and working great).