[Vienna-pm] Re: unicode
Peter J. Holzer
hjp at wsr.ac.at
Wed Sep 29 12:37:44 CDT 2004
On 2004-09-29 19:18:03 +0200, Peter J. Holzer wrote:
> On 2004-09-29 00:44:30 +0200, peter pilsl wrote:
> > Damit das sortieren mit dem sort funktioniert mache ich ein downgrade
> > und damit das mit dem lc() funktioniert, mache ich vorher wieder ein
> > upgrade.
> > Klingt das zu schwindelig?
>
> Es klingt nach Bug im sort oder falscher Locale-Einstellung. Eigentlich
> sollte Sortieren auch mit utf-8-Strings funktionieren. Wie hast Du die
> locale gesetzt? (und welche Perl-Version, welches OS, welche
> libc-Version etc. ist das?)
Bei mir tuts:
perl 5.8.3. Fedora Core 2 (linux 2.6.8-1.521, glibc 2.3.3).
LANG=en_US.UTF-8
Das Script
#!/usr/bin/perl
use strict;
use warnings;
use locale;
binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";
my @array;
while (<>) {
chomp;
push (@array, $_);
}
@array = sort @array;
for (@array) {
print length($_), ": $_\n";
}
sortiert korrekt:
% ./foo
A
a
b
B
ä
Ä
Z
z
0:
1: a
1: A
1: ä
1: Ä
1: b
1: B
1: z
1: Z
%
hp
--
_ | Peter J. Holzer | Shooting the users in the foot is bad.
|_|_) | Sysadmin WSR / LUGA | Giving them a gun isn't.
| | | hjp at wsr.ac.at | -- Gordon Schumacher,
__/ | http://www.hjp.at/ | mozilla bug #84128
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 388 bytes
Desc: not available
Url : http://mail.pm.org/archives/vienna-pm/attachments/20040929/d760e76d/attachment.bin
More information about the Vienna-pm
mailing list