1--TEST-- 2collator_get_sort_key() icu >= 62.1 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?> 6--FILE-- 7<?php 8 9/* 10 * Get sort keys using various locales 11 */ 12function sort_arrays( $locale, $data ) 13{ 14 $res_str = ''; 15 16 $coll = ut_coll_create( $locale ); 17 18 foreach($data as $value) { 19 $res_val = ut_coll_get_sort_key( $coll, $value ); 20 $res_str .= "source: ".$value."\n". 21 "key: ".bin2hex($res_val)."\n"; 22 } 23 24 return $res_str; 25} 26 27 28function ut_main() 29{ 30 $res_str = ''; 31 32 // Regular strings keys 33 $test_params = array( 34 'abc', 'abd', 'aaa', 35 'аа', 'а', 'z', 36 '', null , '3', 37 'y' , 'i' , 'k' 38 ); 39 40 $res_str .= sort_arrays( 'en_US', $test_params ); 41 42 // Sort a non-ASCII array using ru_RU locale. 43 $test_params = array( 44 'абг', 'абв', 'жжж', 'эюя' 45 ); 46 47 $res_str .= sort_arrays( 'ru_RU', $test_params ); 48 49 // Sort an array using Lithuanian locale. 50 $res_str .= sort_arrays( 'lt_LT', $test_params ); 51 52 return $res_str . "\n"; 53} 54 55include_once( 'ut_common.inc' ); 56ut_run(); 57?> 58--EXPECT-- 59source: abc 60key: 2a2c2e01070107 61source: abd 62key: 2a2c3001070107 63source: aaa 64key: 2a2a2a01070107 65source: аа 66key: 61060601060106 67source: а 68key: 610601050105 69source: z 70key: 5c01050105 71source: 72key: 0101 73source: 74key: 0101 75source: 3 76key: 1901050105 77source: y 78key: 5a01050105 79source: i 80key: 3a01050105 81source: k 82key: 3e01050105 83source: абг 84key: 27060c1001070107 85source: абв 86key: 27060c0e01070107 87source: жжж 88key: 272c2c2c01070107 89source: эюя 90key: 27eef0f401070107 91source: абг 92key: 61060c1001070107 93source: абв 94key: 61060c0e01070107 95source: жжж 96key: 612c2c2c01070107 97source: эюя 98key: 61eef0f401070107 99