1--TEST--
2collator_get_sort_key()
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
7<?php if (version_compare(INTL_ICU_VERSION, '53.1') >=  0) die('skip for ICU < 53.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: 27292b01070107
63source: abd
64key: 27292d01070107
65source: aaa
66key: 27272701070107
67source: аа
68key: 5c0a0a01060106
69source: а
70key: 5c0a01050105
71source: z
72key: 5901050105
73source:
74key: 0101
75source: 3
76key: 1801050105
77source: y
78key: 5701050105
79source: i
80key: 3701050105
81source: k
82key: 3b01050105
83source: абг
84key: 260a161a01070107
85source: абв
86key: 260a161801070107
87source: жжж
88key: 263a3a3a01070107
89source: эюя
90key: 273b3f4501070107
91source: абг
92key: 5c0a161a01070107
93source: абв
94key: 5c0a161801070107
95source: жжж
96key: 5c3a3a3a01070107
97source: эюя
98key: 5d3b3f4501070107
99