1--TEST-- 2Collation customization 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5--FILE-- 6<?php 7 8/* 9 * Check effects of changing misc collattion options. 10 */ 11 12 13function cmp_array( &$coll, $a ) 14{ 15 $res = ''; 16 $prev = null; 17 foreach( $a as $i ) 18 { 19 if( is_null( $prev ) ) 20 $res .= "$i"; 21 else 22 { 23 $eqrc = ut_coll_compare( $coll, $prev, $i ); 24 $eq = $eqrc < 0 ? "<" : ( $eqrc > 0 ? ">" : "=" ); 25 $res .= " $eq $i"; 26 } 27 28 $prev = $i; 29 } 30 $res .= "\n"; 31 32 return $res; 33} 34 35function check_alternate_handling( &$coll ) 36{ 37 $res = ''; 38 39 ut_coll_set_strength( $coll, Collator::TERTIARY ); 40 ut_coll_set_attribute( $coll, Collator::ALTERNATE_HANDLING, Collator::NON_IGNORABLE ); 41 42 $res .= cmp_array( $coll, array( 'di Silva', 'Di Silva', 'diSilva', 'U.S.A.', 'USA' ) ); 43 44 ut_coll_set_attribute( $coll, Collator::ALTERNATE_HANDLING, Collator::SHIFTED ); 45 46 $res .= cmp_array( $coll, array( 'di Silva', 'diSilva', 'Di Silva', 'U.S.A.', 'USA' ) ); 47 48 ut_coll_set_strength( $coll, Collator::QUATERNARY ); 49 50 $res .= cmp_array( $coll, array( 'di Silva', 'diSilva', 'Di Silva', 'U.S.A.', 'USA' ) ); 51 $res .= "\n"; 52 53 return $res; 54} 55 56function ut_main() 57{ 58 $coll = ut_coll_create( 'en_US' ); 59 60 return 61 check_alternate_handling( $coll ); 62} 63 64include_once( 'ut_common.inc' ); 65ut_run(); 66?> 67--EXPECT-- 68di Silva < Di Silva < diSilva < U.S.A. < USA 69di Silva = diSilva < Di Silva < U.S.A. = USA 70di Silva < diSilva < Di Silva < U.S.A. < USA 71