Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

collator.__construct(3) [php man page]

COLLATOR.__CONSTRUCT(3) 						 1						   COLLATOR.__CONSTRUCT(3)

Collator::__construct - Create a collator

SYNOPSIS
public Collator::__construct (string $locale) DESCRIPTION
Creates a new instance of Collator. PARAMETERS
o $locale - The locale whose collation rules should be used. Special values for locales can be passed in - if null is passed for the locale, the default locale's collation rules will be used. If "root" is passed, UCA rules will be used. The Locale attribute is typically the most important attribute for correct sorting and matching, according to the user expectations in different countries and regions. The default UCA ordering will only sort a few languages such as Dutch and Portuguese correctly ("correctly" meaning according to the normal expectations for users of the languages). Otherwise, you need to supply the locale to UCA in order to properly collate text for a given language. Thus a locale needs to be supplied so as to choose a collator that is correctly tai- lored for that locale. The choice of a locale will automatically preset the values for all of the attributes to something that is reasonable for that locale. Thus most of the time the other attributes do not need to be explicitly set. In some cases, the choice of locale will make a difference in string comparison performance and/or sort key length. RETURN VALUES
Returns Collator instance. ERRORS
/EXCEPTIONS Returns an "empty" object on error. You can use intl_get_error_code(3) and/or intl_get_error_message(3) to know what happened. EXAMPLES
Example #1 Collator.__construct(3) example <?php $coll = new Collator( 'en_CA' ); ?> SEE ALSO
Collator.create(3), collator_create(3). PHP Documentation Group COLLATOR.__CONSTRUCT(3)

Check Out this Related Man Page

COLLATOR_SET_STRENGTH(3)						 1						  COLLATOR_SET_STRENGTH(3)

Collator::setStrength - Set collation strength

	Object oriented style

SYNOPSIS
public bool Collator::setStrength (int $strength) DESCRIPTION
Procedural style bool collator_set_strength (Collator $coll, int $strength) The ICU Collation Service supports many levels of comparison (named "Levels", but also known as "Strengths"). Having these categories enables ICU to sort strings precisely according to local conventions. However, by allowing the levels to be selectively employed, searching for a string in text can be performed with various matching conditions. o Primary Level: Typically, this is used to denote differences between base characters (for example, "a" < "b"). It is the strong- est difference. For example, dictionaries are divided into different sections by base character. This is also called the level1 strength. o Secondary Level: Accents in the characters are considered secondary differences (for example, "as" < "as" < "at"). Other differ- ences between letters can also be considered secondary differences, depending on the language. A secondary difference is ignored when there is a primary difference anywhere in the strings. This is also called the level2 strength. Note Note: In some languages (such as Danish), certain accented letters are considered to be separate base characters. In most languages, however, an accented letter only has a secondary difference from the unaccented version of that letter. o Tertiary Level: Upper and lower case differences in characters are distinguished at the tertiary level (for example, "ao" < "Ao" < "ao"). In addition, a variant of a letter differs from the base form on the tertiary level (such as "A" and " "). Another exam- ple is the difference between large and small Kana. A tertiary difference is ignored when there is a primary or secondary differ- ence anywhere in the strings. This is also called the level3 strength. o Quaternary Level: When punctuation is ignored (see Ignoring Punctuations ) at level 13, an additional level can be used to dis- tinguish words with and without punctuation (for example, "ab" < "a-b" < "aB"). This difference is ignored when there is a pri- mary, secondary or tertiary difference. This is also known as the level4 strength. The quaternary level should only be used if ignoring punctuation is required or when processing Japanese text (see Hiragana processing). o Identical Level: When all other levels are equal, the identical level is used as a tiebreaker. The Unicode code point values of the NFD form of each string are compared at this level, just in case there is no difference at levels 14. For example, Hebrew can- tillation marks are only distinguished at this level. This level should be used sparingly, as only code point values differences between two strings is an extremely rare occurrence. Using this level substantially decreases the performance for both incremental comparison and sort key generation (as well as increasing the sort key length). It is also known as level 5 strength. For example, people may choose to ignore accents or ignore accents and case when searching for text. Almost all characters are distin- guished by the first three levels, and in most locales the default value is thus Tertiary. However, if Alternate is set to be Shifted, then the Quaternary strength can be used to break ties among whitespace, punctuation, and symbols that would otherwise be ignored. If very fine distinctions among characters are required, then the Identical strength can be used (for example, Identical Strength distinguishes between the Mathematical Bold Small A and the Mathematical Italic Small A.). However, using levels higher than Tertiary the Identical strength result in significantly longer sort keys, and slower string comparison performance for equal strings. PARAMETERS
o $coll -Collator object. o $strength -Strength to set. Possible values are: o Collator::PRIMARY o Collator::SECONDARY o Collator::TERTIARY o Collator::QUATERNARY o Collator::IDENTICAL o Collator::DEFAULT_STRENGTH RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 collator_set_strength(3) example <?php $arr = array( 'ao', 'Ao', 'ao' ); $coll = collator_create( 'en_US' ); // Sort array using default strength. collator_sort( $coll, $arr ); var_export( $arr ); // Sort array using primary strength. collator_set_strength( $coll, Collator::PRIMARY ); collator_sort( $coll, $arr ); var_export( $arr ); ?> The above example will output: array ( 0 => 'ao', 1 => 'Ao', 2 => 'ao', ) array ( 0 => 'ao', 1 => 'Ao', 2 => 'ao', ) SEE ALSO
Collator constants, collator_get_strength(3). PHP Documentation Group COLLATOR_SET_STRENGTH(3)
Man Page