Back to index

php5  5.3.10
collator_create.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | This source file is subject to version 3.01 of the PHP license,      |
00006    | that is bundled with this package in the file LICENSE, and is        |
00007    | available through the world-wide-web at the following url:           |
00008    | http://www.php.net/license/3_01.txt                                  |
00009    | If you did not receive a copy of the PHP license and are unable to   |
00010    | obtain it through the world-wide-web, please send a note to          |
00011    | license@php.net so we can mail you a copy immediately.               |
00012    +----------------------------------------------------------------------+
00013    | Authors: Vadim Savchuk <vsavchuk@productengine.com>                  |
00014    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
00015    +----------------------------------------------------------------------+
00016  */
00017 
00018 #ifdef HAVE_CONFIG_H
00019 #include "config.h"
00020 #endif
00021 
00022 #include "php_intl.h"
00023 #include "collator_class.h"
00024 #include "collator_create.h"
00025 #include "intl_data.h"
00026 
00027 /* {{{ */
00028 static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
00029 {
00030        char*            locale;
00031        int              locale_len = 0;
00032        zval*            object;
00033        Collator_object* co;
00034 
00035        intl_error_reset( NULL TSRMLS_CC );
00036        object = return_value;
00037        /* Parse parameters. */
00038        if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
00039               &locale, &locale_len ) == FAILURE )
00040        {
00041               intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
00042                      "collator_create: unable to parse input params", 0 TSRMLS_CC );
00043               zval_dtor(return_value);
00044               RETURN_NULL();
00045        }
00046 
00047        INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
00048        co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC );
00049 
00050        if(locale_len == 0) {
00051               locale = INTL_G(default_locale);
00052        }
00053 
00054        /* Open ICU collator. */
00055        co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
00056        INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
00057 }
00058 /* }}} */ 
00059 
00060 /* {{{ proto Collator collator_create( string $locale )
00061  * Create collator.
00062  */
00063 PHP_FUNCTION( collator_create )
00064 {
00065        object_init_ex( return_value, Collator_ce_ptr );
00066        collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
00067 }
00068 /* }}} */
00069 
00070 /* {{{ proto Collator Collator::__construct( string $locale )
00071  * Collator object constructor.
00072  */
00073 PHP_METHOD( Collator, __construct )
00074 {
00075        return_value = getThis();
00076        collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
00077 }
00078 /* }}} */
00079 
00080 /*
00081  * Local variables:
00082  * tab-width: 4
00083  * c-basic-offset: 4
00084  * End:
00085  * vim600: noet sw=4 ts=4 fdm=marker
00086  * vim<600: noet sw=4 ts=4
00087  */