1--TEST--
2collator_get_sort_key() icu >= 56.1
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if (version_compare(INTL_ICU_VERSION, '56.1') < 0) die('skip for ICU >= 56.1'); ?>
7<?php if (version_compare(INTL_ICU_VERSION, '62.1') >=  0) die('skip for ICU < 62.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: 292b2d01070107
63source: abd
64key: 292b2f01070107
65source: aaa
66key: 29292901070107
67source: аа
68key: 60060601060106
69source: а
70key: 600601050105
71source: z
72key: 5b01050105
73source:
74key: 0101
75source: 3
76key: 1801050105
77source: y
78key: 5901050105
79source: i
80key: 3901050105
81source: k
82key: 3d01050105
83source: абг
84key: 26060c1001070107
85source: абв
86key: 26060c0e01070107
87source: жжж
88key: 262c2c2c01070107
89source: эюя
90key: 26eef0f401070107
91source: абг
92key: 60060c1001070107
93source: абв
94key: 60060c0e01070107
95source: жжж
96key: 602c2c2c01070107
97source: эюя
98key: 60eef0f401070107
99