[Vienna-pm] Re: unicode
Karlheinz Zoechling
kh at dartbase.com
Tue Sep 28 16:38:03 CDT 2004
On Tue, 28 Sep 2004 22:13:59 +0200, peter pilsl wrote:
okay, ich hab' ein bisschen herumgetan:
> $sr="\x{00e4}-\x{0062}-\x{00f6}-\x{0061}-\x{006f}-\x{0070}-\x{00c4}-\x
{0042}-\x{00d6}-\x{0041}-\x{004f}-\x{0050}";
># ä-b-ö-a-o-p-Ä-B-Ö-A-O-P
perl weiss hier noch nicht dass dein string unicode ist - bisher ist es ja
nur ein string mit zeichen in \x notation, das ist noch nicht automatisch
unicode - also:
utf8::upgrade($sr);
(ja, ich weiss ich hab geschrieben dass man das nicht nehmen soll... ;-) )
jetzt sollte dein script korrekt lowercasen und konsistent (aber leider
immer noch falsch) sortieren.
also muss man noch das sort veraendern, denn das scheint mit dem eingebauten
perl sort nicht zu gehen (ich hab noch nie unicode gesortet, thank god...),
und dazu gibts - angeblich - Unicode::Collate :
use strict;
use Unicode::Collate;
our $Collator = Unicode::Collate->new();
und dann:
sub usort{
# get a string, split by "-", sort and return the joined sorted string
#
my $s=shift;
return join("-",$Collator->sort( split("-",$s)));
}
probier' das mal. ;-)
lg
karlheinz
More information about the Vienna-pm
mailing list