- 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ße',
    'flüße',
);

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";
?>
This commit is contained in:
Derick Rethans 2006-03-26 11:06:24 +00:00
parent 150c896dae
commit ad6a972de3
7 changed files with 338 additions and 35 deletions

View file

@ -57,7 +57,16 @@ PHP_MINFO_FUNCTION(unicode);
PHP_FUNCTION(i18n_loc_get_default);
PHP_FUNCTION(i18n_loc_set_default);
PHP_FUNCTION(collator_create);
PHP_FUNCTION(collator_compare);
PHP_FUNCTION(collator_sort);
PHP_FUNCTION(collator_set_strength);
PHP_FUNCTION(collator_set_attribute);
PHP_FUNCTION(collator_get_strength);
PHP_FUNCTION(collator_get_attribute);
PHP_METHOD(collator, __construct);
void php_init_collation(TSRMLS_D);
extern php_stream_filter_factory php_unicode_filter_factory;
#ifdef __cplusplus