PHP intl APIs - part 1

[email protected] (Stanislav Malyshev) Tue, 17 Jul 2007 18:53:22 -0700
Newsgroups php.i18n
Organization Zend Technologies
Message-ID <[email protected]>
Attached are API descriptions for two ICU modules - collation and number 
formatting. The descriptions will also be checked into PECL module named 
"intl", and the actual code will follow soon.
-- 
Stanislav Malyshev, Zend Software Architect
[email protected]   http://www.zend.com/
(408)253-8829   MSN: [email protected]
formatter_api.php (application/x-httpd-php, 14.2 KB)
<?php

/**
 * Number formatter class - locale-dependent number formatting/parsing.
 *
 * This class represents the ICU number formatting functionality. It allows to display
 * number according to the localized format or given pattern or set of rules, and to
 * parse strings into numbers according to the above patterns.
 *
 * Example:
 * <code>
 * $value = 1234567;
 * $formatter = new NumberFormatter("de_DE", NumberFormatter::DECIMAL);
 * echo $formatter->format($value);
 * </code>
 *
 * @see http://www.icu-project.org/apiref/icu4c/unum_8h.html
 * @see http://www.icu-project.org/apiref/icu4c/classNumberFormat.html
 *
 * The class would also contain all the constants listed in the following enums:
 * UNumberFormatStyle, UNumberFormatRoundingMode, UNumberFormatPadPosition,
 * UNumberFormatAttribute, UNumberFormatTextAttribute, UNumberFormatSymbol.
 */
class NumberFormatter {
	/*
	 * These constants define formatter/parser argument type - integer, floating point or currency.
	 */
	const TYPE_INT32 = 1;
	const TYPE_INT64 = 2;
	const TYPE_DOUBLE = 3;
	const TYPE_CURRENCY = 4;

	/**
	 * Create a number formatter
	 *
	 * Creates a number formatter from locale and pattern. This formatter would be used to
	 * format or parse numbers.
	 *
	 * @param integer $style     Style of the formatting, one of the UNumberFormatStyle constants
	 * @param string $locale     Locale in which the number would be formatted
	 * @param [string] $pattern  Pattern string in case chose style requires pattern
	 * @return NumberFormatter
	 */
	public function __construct($locale, $style, $pattern = null) {}
	
	/**
	 * Create a number formatter
	 *
	 * Creates a number formatter from locale and pattern. This formatter would be used to
	 * format or parse numbers.
	 *
	 * @param integer  $style    Style of the formatting, one of the UNumberFormatStyle constants
	 * @param string   $locale   Locale in which the number would be formatted
	 * @param [string] $pattern  Pattern string in case chose style requires pattern
	 * @return NumberFormatter
	 * @see __construct
	 * @see formatter_create
	 */
	public static function create($locale, $style, $pattern = null) {}

	/**
	 * Format a number according to current formatting rules.
	 *
	 * If the type is not specified, the type is derived from the $number parameter. I.e., if it's
	 * integer then INT32 would be chosen on 32-bit, INT64 on 64-bit, if it's double, DOUBLE would be
	 * chosen. It is possible to format 64-bit number on 32-bit machine by passing it as double and using
	 * TYPE_INT64.
	 * When formatting currency, default formatter's currency name is used.
	 *
	 * @param integer|double $number Number to format
	 * @param [integer]      $type   Type of the formatting - one of TYPE constants. If not specified, default for the type.
	 * @return string formatted number
	 */
	public function format($number, $type = 0) {}

	/**
	 * Parse a number according to current formatting rules.
	 *
	 * This parser requires type though we migh make it use INT32/INT64 by default. When parsing currency,
	 * default currency definitions are used.
	 *
	 * @param string                 $string String to parse
	 * @param integer                $type type of the formatting - one of TYPE constants.
	 * @return integer|double|false  Parsed number, false if parsing failed
	 */
	public function parse($string, $type) {}

	/**
	 * Format number as currency.
	 *
	 * Uses user-defined currency string.
	 *
	 * @param double $number    Number to format
	 * @param string $currency  Currency name to use in format
	 */
	public function formatCurrency($number, $currency) {}

	/**
	 * Parse currency string
	 *
	 * This parser would use parseCurrency API string to parse currency string. The format is defined by the
	 * formatter, returns both number and currency name.
	 *
	 * @param string $string    String to parse
	 * @param string $currency  Parameter to return parsed currency name
	 * @return double currency number
	 */
	public function parseCurrency($string, &$currency) {}

	/**
	 * Set formatter attribute.
	 *
	 * This function is used to set any of the formatter attributes. Example:
	 *
	 * $formatter->setAttribute(NumberFormat::FORMAT_WIDTH, 10);
 	 *
	 * @param integer        $attr  One of UNumberFormatAttribute constants
	 * @param integer|double $value Value of the attribute
	 * @return false if attribute is unknown or can not be set, true otherwise
	 */
	public function setAttribute($attr, $value) {}
	/**
	 * Set formatter attribute.
	 *
	 * This function is used to set any of the formatter attributes. Example:
	 *
	 * $formatter->setTextAttribute(NumberFormat::POSITIVE_PREFIX, "+");
 	 *
	 * @param integer $attr  One of UNumberFormatTextAttribute constants
	 * @param string  $value Value of the attribute
	 * @return false if attribute is unknown or can not be set, true otherwise
	 */
	public function setTextAttribute($attr, $value) {}
	/**
	 * Set formatting symbol.
	 *
	 * Example:
	 *
	 * $formatter->setSymbol(NumberFormat::EXPONENTIAL_SYMBOL, "E");
	 *
	 * @param integer|array $attr  One of UNumberFormatSymbol constants or array of symbols, indexed by
	 * 								these constants
	 * @param string        $value Value of the symbol
	 */
	public function setSymbol($attr, $value) {}
	/**
	 * Set pattern used by the formatter
	 *
	 * Valid only if the formatter is using pattern and is not rule-based.
	 * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html
	 * Localized patterns are not currently supported.
	 *
	 * @param string $pattern  The pattern to be used.
	 * @return boolean         false if formatter pattern could not be set, true otherwise
	 */
	public function setPattern($pattern) {}
	/**
	 * Get value of the formatter attribute
	 *
	 * @param integer $attr One of UNumberFormatAttribute constants
	 * @return integer|double value of the attribute or false if the value can not be obtained
	 */
	public function getAttribute($attr) {}
	/**
	 * Get value of the formatter attribute
	 *
	 * @param integer $attr One of UNumberFormatTextAttribute constants
	 * @return string value of the attribute or false if the value can not be obtained
	 */
	public function getTextAttribute($attr) {}
	/**
	 * Get value of the formatter symbol
	 *
	 * @param integer $attr One of UNumberFormatSymbol constants specifying the symbol
	 * @return string|false The symbol value, or false if the value can not be obtained
	 */
	public function getSymbol($attr) {}
	/**
	 * Get pattern used by the formatter.
	 *
	 * Gets current state of the formatter as a pattern.
	 * Localized patterns are not currently supported.
	 *
	 * Valid only if the formatter is UNUM_PATTERN_DECIMAL
	 * @return string|false The pattern used by the formatter or false if formatter is of a type
	 *                      that does not support patterns.
	 */
	public function getPattern() {}
	/**
	 * Get the locale for which the formatter was created.
	 *
	 * @param [integer] $type One of  ULocDataLocaleType  values
	 * @return string locale name
	 */
	public function getLocale($type = 0) {}
	/**
	 * Get the error code from last operation
	 *
	 * Returns error code from the last number formatting operation.
	 *
	 * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.
	 */
	public function getErrorCode() {}
	/**
	 * Get the error text from the last operation.
	 *
	 * @return string Description of the last occured error.
	 */
	public public function getErrorMessage() {}

}

/** Now the same as procedural API */

/**
 * Create a number formatter
 *
 * Creates a number formatter from locale and pattern. This formatter would be used to
 * format or parse numbers.
 *
 * @param string   $locale   Locale in which the number would be formatted
 * @param integer  $style    Style of the formatting, one of the UNumberFormatStyle constants
 * @param [string] $pattern  Pattern string in case chose style requires pattern
 * @return Numberformatter resource NumberFormatter
 */
function formatter_create($locale, $style, $pattern = null) {}
/**
 * Format a number according to current formatting rules.
 *
 * If the type is not specified, the type is derived from the $number parameter. I.e., if it's
 * integer then INT32 would be chosen on 32-bit, INT64 on 64-bit, if it's double, DOUBLE would be
 * chosen. It is possible to format 64-bit number on 32-bit machine by passing it as double and using
 * TYPE_INT64.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer|double  $number	 Number to format
 * @param [integer]       $type		 Type of the formatting - one of TYPE constants. If not specified, default for the type.
 * @return string formatted number
 */
function formatter_format($formatter, $number, $type = null) {}
/**
 * Parse a number according to current formatting rules.
 *
 * This parser requires type though we migh make it use INT32/INT64 by default. When parsing currency,
 * default currency definitions are used.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param string                 $string String to parse
 * @param integer                $type   Type of the formatting - one of TYPE constants.
 * @return integer|double|false  Parsed number, false if parsing failed
 */
function formatter_parse($formatter, $string, $type) {}
/**
 * Format number as currency.
 *
 * Uses user-defined currency string.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param double          $number    Number to format
 * @param string $currency  Currency name to use in format
 */
function formatter_format_currency($formatter, $number, $currency) {}
/**
 * Parse currency string
 *
 * This parser would use parseCurrency API string to parse currency string. The format is defined by the
 * formatter, returns both number and currency name.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param string          $string    String to parse
 * @param string          $currency  Parameter to return parsed currency name
 * @return double currency number
 */
function formatter_parse_currency($formatter, $string, &$currency) {}
/**
 * Set formatter attribute.
 *
 * This function is used to set any of the formatter attributes. Example:
 *
 * formatter_format_set_attribute($formatter, NumberFormat::FORMAT_WIDTH, 10);
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer         $attr      One of UNumberFormatAttribute constants
 * @param integer|double  $value     Value of the attribute
 * @return false if attribute is unknown or can not be set, true otherwise
 */
function formatter_set_attribute($formatter, $attribute, $value) {}
/**
 * Set formatter attribute.
 *
 * This function is used to set any of the formatter attributes. Example:
 *
 * formatter_format_set_text_attribute($formatter, NumberFormat::POSITIVE_PREFIX, "+");
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer         $attr      One of UNumberFormatTextAttribute constants
 * @param string          $value     Value of the attribute
 * @return false if attribute is unknown or can not be set, true otherwise
 */
function formatter_set_text_attribute($formatter, $attribute, $value) {}
/**
 * Set formatting symbol.
 *
 * Example:
 *
 * $formatter->setSymbol(NumberFormat::EXPONENTIAL_SYMBOL, "E");
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer|array   $attr      One of UNumberFormatSymbol constants or array of symbols, 
 *                                   indexed by these constants
 * @param string $value Value of the symbol
 */
function formatter_set_symbol($formatter, $attribute, $value) {}
/**
 * Set pattern used by the formatter
 *
 * Valid only if the formatter is using pattern and is not rule-based.
 * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html
 * Localized patterns are not currently supported.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param string          $pattern   The pattern to be used.
 * @return boolean false if formatter pattern could not be set, true otherwise
 */
function formatter_set_pattern($formatter, $pattern) {}
/**
 * Get value of the formatter attribute
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer         $attribute One of UNumberFormatAttribute constants
 * @return integer|double value of the attribute or false if the value can not be obtained
 */
function formatter_get_attribute($formatter, $attribute) {}
/**
 * Get value of the formatter attribute
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer         $attribute One of UNumberFormatTextAttribute constants
 * @return string value of the attribute or false if the value can not be obtained
 */
function formatter_get_text_attribute($formatter, $attribute) {}
/**
 * Get value of the formatter symbol
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param integer         $attribute One of UNumberFormatSymbol constants specifying the symbol
 * @return string|false The symbol value, or false if the value can not be obtained
 */
function formatter_get_symbol($formatter, $attribute) {}
/**
 * Get pattern used by the formatter.
 *
 * Gets current state of the formatter as a pattern.
 * Localized patterns are not currently supported.
 *
 * Valid only if the formatter is   UNUM_PATTERN_DECIMAL
 * @param NumberFormatter $formatter The formatter resource
 * @return string|false The pattern used by the formatter or false if formatter is of a type
 *                      that does not support patterns.
 */
function formatter_get_pattern($formatter) {}
/**
 * Get the locale for which the formatter was created.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @param [integer]       $type      One of ULocDataLocaleType values
 * @return string locale name
 */
function formatter_get_locale($formatter, $type = 0) {}
/**
 * Get the error code from last operation
 *
 * Returns error code from the last number formatting operation.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.
 */
function formatter_get_error_code($formatter) {}
/**
 * Get the error text from the last operation.
 *
 * @param NumberFormatter $formatter The formatter resource
 * @return string Description of the last occured error.
 */
function formatter_get_error_message($formatter) {}

?>
collator_api.php (application/x-httpd-php, 13.7 KB)
<?php
#############################################################################
# Object-oriented API
#############################################################################

/**
 * Collator class.
 *
 * This is a wrapper around ICU Collator C API (declared in ucol.h).
 *
 * Example:
 * <code>
 *
 * </code>
 *
 * @see http://www.icu-project.org/apiref/icu4c/ucol_8h.html
 * @see http://www.icu-project.org/apiref/icu4c/classCollator.html
 *
 */
class Collator {
#############################################################################
# Common constants.
#############################################################################

/**
 * Locale-related constants.
 *
 * These will be moved out of Collator when Locale class is created.
 */
	const ULOC_ACTUAL_LOCALE    = 0;
	const ULOC_VALID_LOCALE     = 1;
	const ULOC_REQUESTED_LOCALE = 2;

	/*
	 * WARNING:
	 * The values described here are NOT the actual values in PHP code.
	 * They are references to the ICU C definitions, so the line
	 *    const DEFAULT_STRENGTH = 'UCOL_DEFAULT_STRENGTH';
	 * actually means that Collator::DEFAULT_STRENGTH is the same as
	 * UCOL_DEFAULT_STRENGTH constant in the ICU library.
	 */
	/**
     * Valid attribute values.
     *
     * @see Collator::setAttribute()
     * @see collator_set_attribute()
     */
    const DEFAULT_VALUE    = 'UCOL_DEFAULT';
    const PRIMARY          = 'UCOL_PRIMARY';
    const SECONDARY        = 'UCOL_SECONDARY';
    const TERTIARY         = 'UCOL_TERTIARY';
    const DEFAULT_STRENGTH = 'UCOL_DEFAULT_STRENGTH';
    const QUATERNARY       = 'UCOL_QUATERNARY';
    const IDENTICAL        = 'UCOL_IDENTICAL';
    const OFF              = 'UCOL_OFF';
    const ON               = 'UCOL_ON';
    const SHIFTED          = 'UCOL_SHIFTED';
    const NON_IGNORABLE    = 'UCOL_NON_IGNORABLE';
    const LOWER_FIRST      = 'UCOL_LOWER_FIRST';
    const UPPER_FIRST      = 'UCOL_UPPER_FIRST';

    /**
     * Valid attribute names.
     *
     * @see Collator::setAttribute()
     * @see collator_set_attribute()
     */
    const FRENCH_COLLATION         = 'UCOL_FRENCH_COLLATION';
    const ALTERNATE_HANDLING       = 'UCOL_ALTERNATE_HANDLING';
    const CASE_FIRST               = 'UCOL_CASE_FIRST';
    const CASE_LEVEL               = 'UCOL_CASE_LEVEL';
    const NORMALIZATION_MODE       = 'UCOL_NORMALIZATION_MODE';
    const STRENGTH                 = 'UCOL_STRENGTH';
    const HIRAGANA_QUATERNARY_MODE = 'UCOL_HIRAGANA_QUATERNARY_MODE';
    const NUMERIC_COLLATION        = 'UCOL_NUMERIC_COLLATION';

    /**
     * Create a collator
     *
     * @param string $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 collation rules will be used. If
     *                       empty string ("") or "root" are passed,
     *                       UCA rules will be used.
     *
     * @return Collator     New instance of Collator object.
     */
    public function __construct( $locale ) {}

    /**
     * Create a collator
     *
     * Creates a new instance of Collator.
     *
     * This method is useful when you don't want to deal with exceptions,
     * preferring just to get null on error,
     * as if you called collator_create().
     *
     * @return Collator      Newly created Collator instance,
     *                       or null on error.
     *
     * @see __construct()
     * @see collator_create()
     */
    public static function create( $locale ) {}

    /**
     * Get collator's last error code.
     *
     * @return  int  Error code returned by the last
     *               Collator method call.
     */
    public function getErrorCode() {}

    /**
     * Return error text for the last ICU operation.
     *
     * @return string Description of an error occured in the last
     *                Collator method call.
     */
    public function getErrorMessage() {}

    /**
     * Compare two strings using PHP strcmp() semantics.
     *
     * Wrapper around ICU ucol_strcoll().
     *
     * @param string $str1  First string to compare.
     * @param string $str2  Second string to compare.
     *
     * @return int   1   if $str1 is  greater than  $str2;
     *               0   if $str1 is  equal to      $str2;
     *               -1  if $str1 is  less than     $str2.
     *               On error false is returned.
     */
    public function compare( $str1, $str2 ) {}

    /**
     * Equivalent to standard PHP sort() using Collator.
     *
     * @param array $arr         Array of strings to sort
     * @param int   $sort_flags  Optional sorting type, one of the following:
     *                           - SORT_REGULAR - compare items normally (don't change types)
     *                           - SORT_NUMERIC - compare items numerically
     *                           - SORT_STRING - compare items as strings
     *                           Default sorting type is SORT_REGULAR.
     *
     * @return bool true on success or false on failure.
     */
    public function sort( $arr, $sort_flags ) {}

    /**
     * Sort array maintaining index association.
     *
     * Equivalent to standard PHP asort() using Collator.
     *
     * @param array $arr         Array of strings to sort
     * @param int   $sort_flags  Optional sorting type
     *
     * @return bool true on success or false on failure.
     *
     * @see Collator::sort()
     */
    public function asort( $arr, $sort_flags ) {}

    /**
     * Equivalent to standard PHP sort() using Collator.
     *
     * Similar to Collator::sort().
     * Uses ICU ucol_getSortKey() to gain more speed on large arrays.
     *
     * @param array $arr  Array of strings to sort
     *
     * @return bool       true on success or false on failure.
     */
    public function sortWithSortKeys( $arr ) {}

    /**
     * @todo  Do we want to support other standard PHP sort functions:  ksort, rsort, asort?
     */

    /**
     * Get collation attribute value.
     *
     * Wrapper around ICU ucol_getAttribute().
     *
     * @param  int      $attr Attribute to get value for.
     *
     * @return int      Attribute value, or false on error.
     */
    public function getAttribute( $attr ) {}

    /**
     * Set collation attribute.
     *
     * Wrapper around ICU ucol_setAttribute().
     *
     * @param int       $attr Attribute.
     * @param int       $val  Attribute value.
     *
     * @return bool     true on success, false otherwise.
     */
    public function setAttribute( $attr, $val ) {}

    /**
     * Get current collation strength.
     *
     * Wrapper around ICU ucol_getStrength().
     *
     * @return int     Current collation strength, or false on error.
     */
    public function getStrength() {}

    /**
     * Set collation strength.
     *
     * Wrapper around ICU ucol_setStrength().
     *
     * @param int      $strength Strength to set.
     *
     * @return bool    true on success, false otherwise.
     */
    public function setStrength( $strength ) {}

    /**
     * Get the locale name of the collator.
     *
     * Wrapper around ICU ucol_getLocaleByType().
     *
     * @param int      $type You can choose between requested, valid
     *                       and actual locale
     *                       (ULOC_REQUESTED_LOCALE,
     *                       ULOC_VALID_LOCALE, ULOC_ACTUAL_LOCALE,
     *                       respectively).
     *
     * @return string        Real locale name from which the
     *                       collation data comes. If the collator
     *                       was instantiated from rules or an error occured,
     *                       returns false.
     */
    public function getLocale( $type ) {}

    /**
     * Get the display name for a locale.
     *
     * Wrapper around ICU ucol_getDisplayName().
     *
     * The display name is suitable for presentation to a user.
     *
     * @param  string  $obj_loc   Locale to get display name for.
     * @param  string  $disp_loc  Locale for display.
     *
     * @return string  Locale name, or false on error.
     */
    public static function getDisplayName( $obj_loc, $disp_loc ) {}

    /**
     * Get a list of all locales for which a valid collator may be
     * opened.
     *
     * Wrapper around ICU Collator::getAvailableLocales().
     *
     * @return array(string) The list of available locales, or false
     *                       on error.
     */
    public static function getAvailableLocales() {}
}

#############################################################################
# Procedural API
#############################################################################

/**
 * Create collator.
 *
 * @param string     $locale  The locale containing the required
 *                            collation rules. Special values for
 *                            locales can be passed in - if null is
 *                            passed for the locale, the default
 *                            locale collation rules will be used. If
 *                            empty string ("") or "root" are passed,
 *                            UCA rules will be used.
 *
 * @return Collator  New instance of Collator object, or null on error.
 */
function collator_create( $locale ) {}

/**
 * Compare two strings.
 *
 * The strings will be compared using the options already
 * specified.
 *
 * @param Collator $coll Collator object.
 * @param string   $str1 The first string to compare.
 * @param string   $str2 The second string to compare.
 *
 * @return int     1   if $str1 is  greater than  $str2;
 *                 0   if $str1 is  equal to      $str2;
 *                 -1  if $str1 is  less than     $str2.
 *                 On error false is returned.
 *
 */
function collator_compare( $coll, $str1, $str2 ) {}

/**
 * Sort array using specified collator.
 *
 * @param  Collator $coll        Collator object.
 * @param  array    $arr         Array of strings to sort.
 * @param  int      $sort_flags  Optional sorting type, one of the following:
 *                               - SORT_REGULAR - compare items normally (don't change types)
 *                               - SORT_NUMERIC - compare items numerically
 *                               - SORT_STRING - compare items as strings
 *                               Default sorting type is SORT_REGULAR.
 *
 * @return bool     true on success or false on failure.
 */
function collator_sort( $coll, $arr, $sort_flags ) {}

/**
 * Sort array maintaining index association.
 *
 * @param Collator $coll        Collator object.
 * @param array    $arr         Array of strings to sort.
 * @param int      $sort_flags  Optional sorting type.
 *
 * @return bool    true on success or false on failure.
 *
 * @see collator_sort()
 */
function collator_asort( $coll, $arr, $sort_flags ) {}

/**
 * Sort array using specified collator.
 *
 * Similar to collator_sort().
 * Uses ICU ucol_getSortKey() to gain more speed on large arrays.
 *
 * @param  Collator $coll  Collator object.
 * @param  array    $arr   Array of strings to sort
 *
 * @return bool     true on success or false on failure.
 */
function collator_sort_with_sort_keys( $coll, $arr ) {}

/**
 * Gets the locale name of the collator.
 *
 * @param Collator $coll Collator object.
 * @param int      $type You can choose between requested, valid
 *                       and actual locale
 *                       (ULOC_REQUESTED_LOCALE,
 *                       ULOC_VALID_LOCALE, ULOC_ACTUAL_LOCALE,
 *                       respectively).
 *
 * @return string  Real locale name from which the
 *                 collation data comes. If the collator
 *                 was instantiated from rules or an error occured,
 *                 returns false.
 */
function collator_get_locale( $coll, $type ) {}

/**
 * Get the display name for a locale.
 *
 * The display name is suitable for presentation to a user.
 *
 * @param string   $obj_loc   Locale to get display name for.
 * @param string   $disp_loc  Locale for display.
 *
 * @return string  Locale name, or false on error.
 */
function collator_get_display_name( $obj_loc, $disp_loc ) {}


/**
 * Get a list of all locales for which a valid collator may be
 * opened.
 *
 * @return array(string) The list of available locales, or false
 *                       on error.
 */
function collator_get_available_locales() {}

/**
 * Get collation attribute value.
 *
 * @param  Collator $coll Collator object.
 * @param  int      $attr Attribute to get value for.
 *
 * @return int      Attribute value, or false on error.
 */
function collator_get_attribute( $coll, $attr ) {}

/**
 * Get current collation strength.
 *
 * @param Collator $coll Collator object.
 *
 * @return int     Current collation strength, or false on error.
 */
function collator_get_strength( $coll ) {}

/**
 * Set collation strength.
 *
 * @param Collator $coll      Collator object.
 * @param int      $strength  Strength to set.
 *
 * @return bool    true on success, false otherwise.
 */
function collator_set_strength( $coll, $strength ) {}

/**
 * Set collation attribute.
 *
 * @param Collator  $coll  Collator object.
 * @param int       $attr  Attribute.
 * @param int       $val   Attribute value.
 *
 * @return bool     true on success, false otherwise.
 */
function collator_set_attribute( $coll, $attr, $val ) {}

/**
 * Get collator's last error code.
 *
 * @param Collator $coll    Collator object.
 *
 * @return int     Error code returned by the last
 *                 Collator API function call.
 */
function collator_get_error_code( $coll ) {}

/**
 * Get text for collator's last error code.
 *
 * @param Collator $coll    Collator object.
 *
 * @return string  Description of an error occured in the last
 *                 Collator API function call.
 */
function collator_get_error_message( $coll ) {}
?>
common_api.php (application/x-httpd-php, 1.2 KB)
<?php

/**
 * Handling of errors occured in statics methods
 * when there's no object to get error code/message from.
 *
 * Example #1:
 * <code>
 * $coll = collator_create( '<bad_param>' );
 * if( !$coll )
 *     handle_error( intl_get_error_code() );
 * </code>
 *
 * Example #2:
 * <code>
 * if( Collator::getAvailableLocales() === false )
 *     show_error( intl_get_error_message() );
 * </code>
 */

/**
 * Get the last error code.
 *
 * @return int     Error code returned by the last
 *                 API function call.
 */
function intl_get_error_code() {}

/**
 * Get description of the last error.
 *
 * @return string  Description of an error occured in the last
 *                 API function call.
 */
function intl_get_error_message() {}

/**
 * Check whether the given error code indicates failure.
 *
 * @param $code integer ICU error code. 
 * @return bool true if it the code indicates some failure,
 *              and false in case of success or a warning.
 */
function intl_is_failure($code) {}

/**
 * Get symbolic name for a given error code.
 *
 * The returned string will be the same as the name of the error code constant.
 *
 * @param $code integer ICU error code. 
 * @return string Error code name.
 */
function intl_error_name($code) {}

?>