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