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