1--TEST-- 2collator_get_sort_key() icu >= 54.1 3--SKIPIF-- 4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> 5<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.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: 292b2d01070107 61source: abd 62key: 292b2f01070107 63source: aaa 64key: 29292901070107 65source: аа 66key: 5e060601060106 67source: а 68key: 5e0601050105 69source: z 70key: 5b01050105 71source: 72key: 0101 73source: 74key: 0101 75source: 3 76key: 1a01050105 77source: y 78key: 5901050105 79source: i 80key: 3901050105 81source: k 82key: 3d01050105 83source: абг 84key: 2806101401070107 85source: абв 86key: 2806101201070107 87source: жжж 88key: 2830303001070107 89source: эюя 90key: 28ccd0d401070107 91source: абг 92key: 5e06101401070107 93source: абв 94key: 5e06101201070107 95source: жжж 96key: 5e30303001070107 97source: эюя 98key: 5eccd0d401070107 99