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