Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re: Bug with locale #160

Closed
p5pRT opened this issue Jul 4, 1999 · 1 comment
Closed

Re: Bug with locale #160

p5pRT opened this issue Jul 4, 1999 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Jul 4, 1999

Migrated from rt.perl.org#965 (status was 'resolved')

Searchable as RT965$

@p5pRT
Copy link
Author

p5pRT commented Jul 4, 1999

From @jhi

Jan Starzynski writes​:

Hello,

there seems to be a bug then using locales. The following script
(sorting strings case-independently) demonstrates this​:

****************************************************************
#!/usr#!/usr/bin/perl -w

use locale;

$, = "\t";
$\ = "\n";
@​list = qw(perltk perl PERLTK PERL );

print "original​:", @​list;
print "correct​: ", sort NoCaseWithCopy @​list;
print "wrong​: ", sort NoCaseWithoutCopy @​list;

sub NoCaseWithCopy {
my $aa = lc $a;
my $bb = lc $b;
$aa cmp $bb || $a cmp $b
}

sub NoCaseWithoutCopy {
lc($a) cmp lc($b) || $a cmp $b
}
****************************************************************

The output is as follows​:
****************************************************************
original​: perltk perl PERLTK PERL
correct​: PERL perl PERLTK perltk
wrong​: PERL PERLTK perl perltk
****************************************************************

When the 'use locale'-line is absent everything works fine.

I'm using a Linux 2.0.36 machine, Perl was compiled with gcc 2.7.2.2. I
tried the Perl-Versions 5.00404, 5.000 and 5.00503 and all have this
bug. The value of $ENV{LANG} seems to have no influence on the results.

--
Live long and
prosper!
Your mind understands what you have been taught; Jan Starzynski
your heart, what is true. jan@​planet.de
No advertising!

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant