1--TEST--
2create() icu >= 53.1
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
7--FILE--
8<?php
9
10/*
11 * Try creating collator with different locales
12 * with Procedural and Object methods.
13 */
14
15function ut_main()
16{
17    $res_str = '';
18
19    $locales = array(
20        'EN-US-ODESSA',
21        'UK_UA_ODESSA',
22        'uk-ua_CALIFORNIA@currency=;currency=GRN',
23        '',
24        'root',
25        'uk@currency=EURO',
26    '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
27    );
28
29    foreach( $locales as $locale )
30    {
31        // Create Collator with the current locale.
32        $coll = ut_coll_create( $locale );
33        if( !is_object($coll) )
34        {
35            $res_str .= "Error creating collator with '$locale' locale: " .
36                 intl_get_error_message() . "\n";
37            continue;
38        }
39
40        // Get the requested, valid and actual locales.
41        $vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
42        $aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
43
44        // Show them.
45        $res_str .= "Locale: '$locale'\n" .
46            "  ULOC_REQUESTED_LOCALE = '$locale'\n" .
47            "  ULOC_VALID_LOCALE     = '$vloc'\n" .
48            "  ULOC_ACTUAL_LOCALE    = '$aloc'\n";
49    }
50
51    return $res_str;
52}
53
54include_once( 'ut_common.inc' );
55ut_run();
56
57?>
58--EXPECTF--
59Locale: 'EN-US-ODESSA'
60  ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
61  ULOC_VALID_LOCALE     = 'en_US'
62  ULOC_ACTUAL_LOCALE    = 'root'
63Locale: 'UK_UA_ODESSA'
64  ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
65  ULOC_VALID_LOCALE     = 'uk'
66  ULOC_ACTUAL_LOCALE    = 'uk'
67Error creating collator with 'uk-ua_CALIFORNIA@currency=;currency=GRN' locale: collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR
68Locale: ''
69  ULOC_REQUESTED_LOCALE = ''
70  ULOC_VALID_LOCALE     = '%s'
71  ULOC_ACTUAL_LOCALE    = '%s'
72Locale: 'root'
73  ULOC_REQUESTED_LOCALE = 'root'
74  ULOC_VALID_LOCALE     = 'root'
75  ULOC_ACTUAL_LOCALE    = 'root'
76Locale: 'uk@currency=EURO'
77  ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
78  ULOC_VALID_LOCALE     = 'uk'
79  ULOC_ACTUAL_LOCALE    = 'uk'
80Error creating collator with '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than %d characters: U_ILLEGAL_ARGUMENT_ERROR
81