Re: php-src /ext/standard array.c php_array.h /ext/unicode collator.c config.m4 config.w32 php_unicode.h unicode.c
| From: | l0t3k | Date: | Sun, 26 Mar 2006 11:42:53 +0000 |
| Subject: | Re: php-src /ext/standard array.c php_array.h /ext/unicode collator.c config.m4 config.w32 php_unicode.h unicode.c | ||
| References: | 1 | Groups: | php.i18n php.internals |
| Request: | Send a blank email to internals+get-22584@lists.php.net to get a copy of this message | ||
Derick,
i know this is the initial dump, but have a look also here :
http://icu.sourceforge.net/userguide/Collate_ServiceArchitecture.html#Sort_Key
For small lists the current implementation is OK, but after a threshold,
sort keys are better performance-wise.
Here's an implementation of mine (untested, unfortunately) which attempts to
use sort-keys as well as accomodating iterators (search for "sort").
Never mind the use of the C++ API, the concept is the same.
http://cvs.iworks.at/co.php/php-i18n/collator.cpp?r=1.3
I actually have a different implementation (strictly C) which switches
between ucol_compare and sort-key generation after a threshold,
but i havent had time to work on it.
l0t3k
""Derick Rethans"" <derick@php.net> wrote in message
news:cvsderick1143371184@cvsserver...
> derick Sun Mar 26 11:06:24 2006 UTC
>
> Added files:
> /php-src/ext/unicode collator.c
>
> Modified files:
> /php-src/ext/standard array.c php_array.h
> /php-src/ext/unicode config.m4 config.w32 php_unicode.h unicode.c
> Log:
> - Implemented basic collation support. For some reason "new Collator"
> gives segfaults when the object's collation resource is used.
> - The following example shows what is implemented:
>
> <?php
> $orig = $strings = array(
> 'côte',
> 'cote',
> 'côté',
> 'coté',
> 'fluÃYe',
> 'flüÃYe',
> );
>
> echo "German phonebook:\n";
> $c = collator_create( "de@collation=phonebook" );
> foreach($c->sort($strings) as $string) {
> echo $string, "\n";
> }
> echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
> ? "With" : "Without", " french accent sorting order\n";
>
> echo "\nFrench with options:\n";
> $c = collator_create( "fr" );
> $c->setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
> $c->setAttribute(Collator::CASE_LEVEL, Collator::ON);
> $c->setStrength(Collator::SECONDARY);
> foreach($c->sort($strings) as $string) {
> echo $string, "\n";
> }
> echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
> ? "With" : "Without", " french accent sorting order\n";
> ?>
>
>