1--TEST-- 2collator_get_sort_key() icu >= 62.1 3--EXTENSIONS-- 4intl 5--SKIPIF-- 6<?php if (version_compare(INTL_ICU_VERSION, '62.1') < 0) die('skip for ICU >= 62.1'); ?> 7<?php if (version_compare(INTL_ICU_VERSION, '76.1') >= 0) die('skip for ICU < 76.1'); ?> 8--FILE-- 9<?php 10 11/* 12 * Get sort keys using various locales 13 */ 14function sort_arrays( $locale, $data ) 15{ 16 $res_str = ''; 17 18 $coll = ut_coll_create( $locale ); 19 20 foreach($data as $value) { 21 $res_val = ut_coll_get_sort_key( $coll, $value ); 22 $res_str .= "source: ".$value."\n". 23 "key: ".bin2hex($res_val)."\n"; 24 } 25 26 return $res_str; 27} 28 29 30function ut_main() 31{ 32 $res_str = ''; 33 34 // Regular strings keys 35 $test_params = array( 36 'abc', 'abd', 'aaa', 37 'аа', 'а', 'z', 38 '', '3', 39 'y' , 'i' , 'k' 40 ); 41 42 $res_str .= sort_arrays( 'en_US', $test_params ); 43 44 // Sort a non-ASCII array using ru_RU locale. 45 $test_params = array( 46 'абг', 'абв', 'жжж', 'эюя' 47 ); 48 49 $res_str .= sort_arrays( 'ru_RU', $test_params ); 50 51 // Sort an array using Lithuanian locale. 52 $res_str .= sort_arrays( 'lt_LT', $test_params ); 53 54 return $res_str . "\n"; 55} 56 57include_once( 'ut_common.inc' ); 58ut_run(); 59?> 60--EXPECT-- 61source: abc 62key: 2a2c2e01070107 63source: abd 64key: 2a2c3001070107 65source: aaa 66key: 2a2a2a01070107 67source: аа 68key: 61060601060106 69source: а 70key: 610601050105 71source: z 72key: 5c01050105 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