Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

any use of 'use locale'?

by wanradt (Scribe)
on Nov 20, 2009 at 00:58 UTC ( #808310=perlquestion: print w/replies, xml ) Need Help??
wanradt has asked for the wisdom of the Perl Monks concerning the following question:

Hello, devoted!

"use locale" should be something easy, but not to me. Following script should populate 2 equal list under my locale (et_EE.UTF-8), but no.

#!/usr/bin/perl use strict; use locale; use POSIX; print setlocale( LC_CTYPE ), "\n\n";; my @real = qw(R S Z); my @fake = 'R'..'Z'; print "@real\n"; print "@fake\n"; __END__ et_EE.UTF-8 R S Z R S T U V W X Y Z

To test locale, i print it with POSIX setlocale , and perl seems see my locale pretty well. But setlocale does not bother about locale-pragma, same output without it too. So, why "use locale" has no influence on alphabet and how to change it?

Nnda, WK

Replies are listed 'Best First'.
Re: any use of 'use locale'?
by ikegami (Pope) on Nov 20, 2009 at 03:10 UTC

      Thank you for suggestion! To be honest, i already did on sept 24th:

      http://pastebin.ca/1679329

      But it seemed to me that perlbug is buggy too, so i made bugreport about perlbug itself:

      http://pastebin.ca/1679330

      Cause i got no any kind of response at all, it seems to me, it was also useless... I did not find any trace of my reports and i don't see public register of perl bug-tickets. Could you point me, what am i missing?

      Nnda, WK

        #!/usr/bin/perl use locale; print uc("abc"), "\n";

        Wait a sec, and aren't found in iso-8859-1. The file you describe can't possibly exist. If the file is encoded using an encoding other than iso-8859-1, you need to tell Perl. use utf8; tells Perl that the source is encoded using UTF-8.

        That applies to the OP of this thread too, although it won't change the outcome.

        Useful commands:

        # Source is UTF-8 use utf8; # Appropriate de/encode data going through STDIN/OUT/ERR. use open ':std', ':locale';

        Yeah, I don't see the first. (Didn't look for the second.) When you use perlbug, it gives the option to "save to file". Then you can use your normal mailer to send the report.

        In other words, take what's on pastebin and send it to perlbug@perl.org. You get sent an automated confirmation message on receipt.

Re: any use of 'use locale'?
by ambrus (Abbot) on Nov 21, 2009 at 16:41 UTC

    I don't think the range (or magical increment) operators are supposed to use a non-ascii alphabet ever.

      perlop says a value that is not the empty string and matches the pattern /^[a-zA-Z]*[0-9]*\z/ and The range operator also works on strings, using the magical auto-increment, see below.
Re: any use of 'use locale'?
by Khen1950fx (Canon) on Nov 23, 2009 at 01:32 UTC
    Just some thoughts... I ran your script as is and I got the following results:

    C R S ? Z R S T U V W X Y Z

    The results tell me that the encoding is the special locale C which maps to ASCII, the ? mark tells you that something is missing. C maps to ASCII, but the does not. I would guess that you have to declare the locale, so I tried this:

    #!/usr/bin/perl use strict; no warnings 'utf8'; use utf8; use POSIX; use locale; print setlocale(LC_CTYPE(), 'et_EE.UTF-8'), "\n\n"; my(@real) = ('R', 'S', '', 'Z'); my(@fake) = ('R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); print "@real\n", "@fake\n";

    And the results:

    et_EE.UTF-8 R S Z R S T U V W X Y Z
    I wasn't comfortable with the range operator, so I deleted that. Personally, I think that it might be a platform-specific problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://808310]
Approved by biohisham
help
Chatterbox?
[Discipulus]: ah i become monsignor the same day of sysadmin day
[marto]: not so great OS :P
Eily never heard of the movie "LanX"
[Eily]: the LanX OS either now that I think of it :P
[hippo]: Congratulations, Discipulus!
[Discipulus]: Satura Lanx was a latin genre of show
[Discipulus]: coming from the meaning of 'mixed dish'
[Discipulus]: thanks hippo! the hat you passed me was brand new and clean, thanks

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-07-28 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (426 votes). Check out past polls.