function sort_using_locale($locale, $test_array)
{
    $coll = ut_coll_create($locale);
    // Sort array.
    ut_coll_sort_with_sort_keys($coll, $test_array);
    // And return the sorted array.
    return dump($test_array) . "\n";
}
function ut_main()
{
    $res = '';
    $coll = ut_coll_create('en_US');
    $res .= check_set_strength($coll, Collator::PRIMARY);
    $res .= check_set_strength($coll, Collator::SECONDARY);
    $res .= check_set_strength($coll, Collator::TERTIARY);
    return $res;
}
function sort_arrays($locale, $data)
{
    $res_str = '';
    $coll = ut_coll_create($locale);
    foreach ($data as $value) {
        $res_val = ut_coll_get_sort_key($coll, $value);
        $res_str .= "source: " . $value . "\n" . "key: " . bin2hex($res_val) . "\n";
    }
    return $res_str;
}
function ut_main()
{
    $res = '';
    $coll = ut_coll_create('en_US');
    ut_coll_set_attribute($coll, Collator::NORMALIZATION_MODE, Collator::OFF);
    $res .= check_val($coll);
    ut_coll_set_attribute($coll, Collator::NORMALIZATION_MODE, Collator::ON);
    $res .= check_val($coll);
    return $res;
}
function ut_main()
{
    $locales = array(Locale::VALID_LOCALE, Locale::ACTUAL_LOCALE, 100, -100, -9999999999999, 9999999999999, 1.2);
    $coll = ut_coll_create('en_US');
    $res_str = '';
    foreach ($locales as $locale) {
        $rc = ut_coll_get_locale($coll, $locale);
        $res_str .= sprintf("Locale of type %s is %s\n", dump($locale), dump($rc));
    }
    return $res_str . "\n";
}
Exemple #6
0
function compare_pairs($locale, $test_array)
{
    $res_str = '';
    $coll = ut_coll_create($locale);
    foreach ($test_array as $test_strings) {
        list($str1, $str2) = $test_strings;
        // Compare strings.
        $res_val = cmp_to_char(ut_coll_compare($coll, $str1, $str2));
        // Concatenate result strings.
        $res_str .= dump($str1) . ' ' . $res_val . ' ' . dump($str2) . "\n";
    }
    return $res_str;
}
function ut_main()
{
    $res = '';
    $coll = ut_coll_create('ru_RU');
    // Try specifying a correct attribute.
    ut_coll_get_attribute($coll, Collator::NORMALIZATION_MODE);
    $status = ut_coll_get_error_code($coll);
    $res .= check_rc($status, U_ZERO_ERROR);
    // Try specifying an incorrect attribute.
    ut_coll_get_attribute($coll, 12345);
    $status = ut_coll_get_error_code($coll);
    $res .= check_rc($status, U_ILLEGAL_ARGUMENT_ERROR);
    return $res;
}
function ut_main()
{
    $res = '';
    $coll = ut_coll_create('ru_RU');
    // Try specifying a correct attribute.
    ut_coll_get_attribute($coll, Collator::NORMALIZATION_MODE);
    $status = ut_coll_get_error_message($coll);
    $res .= $status . "\n";
    // Try specifying an incorrect attribute.
    ut_coll_get_attribute($coll, 12345);
    $status = ut_coll_get_error_message($coll);
    $res .= $status . "\n";
    return $res;
}
function test_COW($locale, $test_array)
{
    $res_str = '';
    $coll = ut_coll_create($locale);
    // Create two copies of the given array.
    $copy1 = $test_array;
    $copy2 = $test_array;
    // Sort given array and the first copy of it.
    ut_coll_sort($coll, $test_array);
    ut_coll_sort($coll, $copy1);
    // Return contents of all the arrays.
    // The second copy should remain unsorted.
    $res_str .= dump($test_array) . "\n";
    $res_str .= dump($copy1) . "\n";
    $res_str .= dump($copy2) . "\n";
    return $res_str;
}
Exemple #10
0
function sort_arrays($locale, $test_arrays, $sort_flag = Collator::SORT_REGULAR)
{
    $res_str = '';
    $coll = ut_coll_create($locale);
    foreach ($test_arrays as $test_array) {
        // Try to sort test data.
        $res_val = ut_coll_asort($coll, $test_array, $sort_flag);
        // Return output data.
        $res_dump = "\n" . dump($test_array) . "\n Result: " . dump($res_val);
        // Preppend test signature to output string
        $md5 = md5($res_dump);
        global $test_num;
        $res_str .= "\n\n" . "Test {$test_num}.{$md5}:" . $res_dump;
        ++$test_num;
    }
    return $res_str;
}
function sort_arrays($locale, $arrays)
{
    $res_str = '';
    $coll = ut_coll_create($locale);
    foreach ($arrays as $array) {
        // Sort array values
        $res_val = ut_coll_sort_with_sort_keys($coll, $array);
        // Concatenate the sorted array and function result
        // with output string.
        $res_dump = "\n" . dump($array) . "\n Result: " . dump($res_val);
        // Preppend test signature to output string
        $md5 = md5($res_dump);
        global $test_num;
        $res_str .= "\n\n" . "Test {$test_num}.{$md5}:" . $res_dump;
        ++$test_num;
    }
    return $res_str;
}
Exemple #12
0
function ut_main()
{
    $res_str = '';
    $locales = array('EN-US-ODESSA', 'UK_UA_ODESSA', 'uk-ua_CALIFORNIA@currency=;currency=GRN', '', 'root', 'uk@currency=EURO', '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799');
    foreach ($locales as $locale) {
        // Create Collator with the current locale.
        $coll = ut_coll_create($locale);
        if (!is_object($coll)) {
            $res_str .= "Error creating collator with '{$locale}' locale: " . intl_get_error_message() . "\n";
            continue;
        }
        // Get the requested, valid and actual locales.
        $vloc = ut_coll_get_locale($coll, Locale::VALID_LOCALE);
        $aloc = ut_coll_get_locale($coll, Locale::ACTUAL_LOCALE);
        // Show them.
        $res_str .= "Locale: '{$locale}'\n" . "  ULOC_REQUESTED_LOCALE = '{$locale}'\n" . "  ULOC_VALID_LOCALE     = '{$vloc}'\n" . "  ULOC_ACTUAL_LOCALE    = '{$aloc}'\n";
    }
    return $res_str;
}
function ut_main()
{
    $coll = ut_coll_create('en_US');
    return check_alternate_handling($coll);
}